mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-07 16:48:31 +02:00
Minor performance fix: Access dpy->xcl->connection directly instead of calling XCBConnectionOfDisplay. It happens a lot.
This commit is contained in:
parent
53c471c6a8
commit
ec30a27341
2 changed files with 14 additions and 14 deletions
12
src/xcl/io.c
12
src/xcl/io.c
|
|
@ -90,7 +90,7 @@ int _XEventsQueued(Display *dpy, int mode)
|
|||
if(dpy->xcl->event_owner != XlibOwnsEventQueue)
|
||||
return 0;
|
||||
|
||||
c = XCBConnectionOfDisplay(dpy);
|
||||
c = dpy->xcl->connection;
|
||||
if(mode == QueuedAfterFlush)
|
||||
_XSend(dpy, 0, 0);
|
||||
else
|
||||
|
|
@ -110,7 +110,7 @@ void _XReadEvents(Display *dpy)
|
|||
_XSend(dpy, 0, 0);
|
||||
if(dpy->xcl->event_owner != XlibOwnsEventQueue)
|
||||
return;
|
||||
handle_event(dpy, XCBWaitForEvent(XCBConnectionOfDisplay(dpy)));
|
||||
handle_event(dpy, XCBWaitForEvent(dpy->xcl->connection));
|
||||
_XEventsQueued(dpy, QueuedAfterReading);
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ void _XReadEvents(Display *dpy)
|
|||
*/
|
||||
void _XSend(Display *dpy, const char *data, long size)
|
||||
{
|
||||
XCBConnection *c = XCBConnectionOfDisplay(dpy);
|
||||
XCBConnection *c = dpy->xcl->connection;
|
||||
|
||||
assert(!dpy->xcl->request_extra);
|
||||
dpy->xcl->request_extra = data;
|
||||
|
|
@ -163,7 +163,7 @@ void _XFlush(Display *dpy)
|
|||
/* _XAllocID - resource ID allocation routine. */
|
||||
XID _XAllocID(Display *dpy)
|
||||
{
|
||||
return XCBGenerateID(XCBConnectionOfDisplay(dpy));
|
||||
return XCBGenerateID(dpy->xcl->connection);
|
||||
}
|
||||
|
||||
/* _XAllocIDs - multiple resource ID allocation routine. */
|
||||
|
|
@ -186,7 +186,7 @@ void _XAllocIDs(Display *dpy, XID *ids, int count)
|
|||
unsigned long _XSetLastRequestRead(Display *dpy, xGenericReply *rep)
|
||||
{
|
||||
unsigned long newseq;
|
||||
unsigned int xcb_seqnum = XCBGetRequestRead(XCBConnectionOfDisplay(dpy));
|
||||
unsigned int xcb_seqnum = XCBGetRequestRead(dpy->xcl->connection);
|
||||
|
||||
/*
|
||||
* KeymapNotify has no sequence number, but is always guaranteed
|
||||
|
|
@ -230,7 +230,7 @@ static void _XFreeReplyData(Display *dpy, Bool force)
|
|||
Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
|
||||
{
|
||||
XCBGenericError *error;
|
||||
XCBConnection *c = XCBConnectionOfDisplay(dpy);
|
||||
XCBConnection *c = dpy->xcl->connection;
|
||||
char *reply;
|
||||
|
||||
assert(!dpy->xcl->reply_data);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
static void _XLockDisplay(Display *dpy)
|
||||
{
|
||||
pthread_mutex_lock(XCBGetIOLock(XCBConnectionOfDisplay(dpy)));
|
||||
pthread_mutex_lock(XCBGetIOLock(dpy->xcl->connection));
|
||||
_XGetXCBBufferIf(dpy, _XBufferUnlocked);
|
||||
++dpy->xcl->lock_count;
|
||||
}
|
||||
|
|
@ -46,14 +46,14 @@ static void _XUnlockDisplay(Display *dpy)
|
|||
* invariants hold. */
|
||||
if(!dpy->xcl->lock_count)
|
||||
{
|
||||
assert(XCBGetRequestSent(XCBConnectionOfDisplay(dpy)) == dpy->request);
|
||||
assert(XCBGetRequestSent(dpy->xcl->connection) == dpy->request);
|
||||
|
||||
/* Traditional Xlib does this in _XSend; see the Xlib/XCB version
|
||||
* of that function for why we do it here instead. */
|
||||
_XSetSeqSyncFunction(dpy);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(XCBGetIOLock(XCBConnectionOfDisplay(dpy)));
|
||||
pthread_mutex_unlock(XCBGetIOLock(dpy->xcl->connection));
|
||||
}
|
||||
|
||||
void XUnlockDisplay(Display* dpy)
|
||||
|
|
@ -67,12 +67,12 @@ int _XInitDisplayLock(Display *dpy)
|
|||
{
|
||||
#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||
*XCBGetIOLock(XCBConnectionOfDisplay(dpy)) = lock;
|
||||
*XCBGetIOLock(dpy->xcl->connection) = lock;
|
||||
#else
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(XCBGetIOLock(XCBConnectionOfDisplay(dpy)), &attr);
|
||||
pthread_mutex_init(XCBGetIOLock(dpy->xcl->connection), &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
#endif
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ void _XGetXCBBuffer(Display *dpy)
|
|||
{
|
||||
static const xReq dummy_request;
|
||||
|
||||
XCBConnection *c = XCBConnectionOfDisplay(dpy);
|
||||
XCBConnection *c = dpy->xcl->connection;
|
||||
|
||||
dpy->last_req = (char *) &dummy_request;
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
}
|
||||
|
||||
/* send the accumulated request. */
|
||||
XCBSendRequest(XCBConnectionOfDisplay(dpy), &sequence, vec, &xcb_req);
|
||||
XCBSendRequest(dpy->xcl->connection, &sequence, vec, &xcb_req);
|
||||
|
||||
/* update the iovecs to refer only to data not yet sent. */
|
||||
vec[i].iov_base = (char *) vec[i].iov_base + vec[i].iov_len;
|
||||
|
|
@ -243,7 +243,7 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
|
||||
void _XPutXCBBuffer(Display *dpy)
|
||||
{
|
||||
XCBConnection *c = XCBConnectionOfDisplay(dpy);
|
||||
XCBConnection *c = dpy->xcl->connection;
|
||||
_XExtension *ext;
|
||||
struct iovec iov[2];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue