mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 13:04:23 -04:00
Remove redundant checks for lock!=NULL before calling EVLOCK_LOCK
The EVLOCK_LOCK and EVLOCK_UNLOCK macros already check to make sure that the lock is present before messing with it, so there's no point in checking the lock before calling them. A good compiler should be able to simplify code like if (lock) { if (lock) acquire(lock); } , but why count on it?
This commit is contained in:
parent
40c301b76c
commit
50ec59f4a6
@ -352,14 +352,12 @@ int _bufferevent_generic_adj_timeouts(struct bufferevent *bev);
|
|||||||
/** Internal: Grab the lock (if any) on a bufferevent */
|
/** Internal: Grab the lock (if any) on a bufferevent */
|
||||||
#define BEV_LOCK(b) do { \
|
#define BEV_LOCK(b) do { \
|
||||||
struct bufferevent_private *locking = BEV_UPCAST(b); \
|
struct bufferevent_private *locking = BEV_UPCAST(b); \
|
||||||
if (locking->lock) \
|
|
||||||
EVLOCK_LOCK(locking->lock, 0); \
|
EVLOCK_LOCK(locking->lock, 0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/** Internal: Release the lock (if any) on a bufferevent */
|
/** Internal: Release the lock (if any) on a bufferevent */
|
||||||
#define BEV_UNLOCK(b) do { \
|
#define BEV_UNLOCK(b) do { \
|
||||||
struct bufferevent_private *locking = BEV_UPCAST(b); \
|
struct bufferevent_private *locking = BEV_UPCAST(b); \
|
||||||
if (locking->lock) \
|
|
||||||
EVLOCK_UNLOCK(locking->lock, 0); \
|
EVLOCK_UNLOCK(locking->lock, 0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user