randr: ProcRRGetOutputInfo() skip payload assembly when nothing to do
If there's no extra payload to send, we can skip the whole payload assembly chain. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
6b5c64d273
commit
b535db955a
|
@ -468,13 +468,14 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
.nameLength = output->nameLength
|
||||
};
|
||||
extraLen = bytes_to_int32(rep.nameLength) << 2;
|
||||
if (extraLen) {
|
||||
rep.length += bytes_to_int32(extraLen);
|
||||
extra = calloc(1, extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
memcpy(extra, output->name, output->nameLength);
|
||||
}
|
||||
if (!extraLen)
|
||||
goto sendout;
|
||||
|
||||
rep.length += bytes_to_int32(extraLen);
|
||||
extra = calloc(1, extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
memcpy(extra, output->name, output->nameLength);
|
||||
} else {
|
||||
rep = (xRRGetOutputInfoReply) {
|
||||
.type = X_Reply,
|
||||
|
@ -497,12 +498,13 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
output->numModes + output->numUserModes +
|
||||
output->numClones + bytes_to_int32(rep.nameLength)) << 2);
|
||||
|
||||
if (extraLen) {
|
||||
rep.length += bytes_to_int32(extraLen);
|
||||
extra = calloc(1, extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
if (!extraLen)
|
||||
goto sendout;
|
||||
|
||||
rep.length += bytes_to_int32(extraLen);
|
||||
extra = calloc(1, extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||
|
@ -515,6 +517,7 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
if (client->swapped)
|
||||
swapl(&crtcs[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < output->numModes + output->numUserModes; i++) {
|
||||
if (i < output->numModes)
|
||||
modes[i] = output->modes[i]->mode.id;
|
||||
|
@ -530,6 +533,7 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
}
|
||||
}
|
||||
|
||||
sendout:
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
|
@ -543,11 +547,10 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
swaps(&rep.nClones);
|
||||
swaps(&rep.nameLength);
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(xRRGetOutputInfoReply), &rep);
|
||||
if (extraLen) {
|
||||
WriteToClient(client, extraLen, extra);
|
||||
free(extra);
|
||||
}
|
||||
WriteToClient(client, extraLen, extra);
|
||||
free(extra);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue