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
ca9e23c263
commit
d0802de141
|
@ -469,13 +469,14 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
.nameLength = output->nameLength
|
.nameLength = output->nameLength
|
||||||
};
|
};
|
||||||
extraLen = bytes_to_int32(rep.nameLength) << 2;
|
extraLen = bytes_to_int32(rep.nameLength) << 2;
|
||||||
if (extraLen) {
|
if (!extraLen)
|
||||||
rep.length += bytes_to_int32(extraLen);
|
goto sendout;
|
||||||
extra = calloc(1, extraLen);
|
|
||||||
if (!extra)
|
rep.length += bytes_to_int32(extraLen);
|
||||||
return BadAlloc;
|
extra = calloc(1, extraLen);
|
||||||
memcpy(extra, output->name, output->nameLength);
|
if (!extra)
|
||||||
}
|
return BadAlloc;
|
||||||
|
memcpy(extra, output->name, output->nameLength);
|
||||||
} else {
|
} else {
|
||||||
rep = (xRRGetOutputInfoReply) {
|
rep = (xRRGetOutputInfoReply) {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
|
@ -498,12 +499,13 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
output->numModes + output->numUserModes +
|
output->numModes + output->numUserModes +
|
||||||
output->numClones + bytes_to_int32(rep.nameLength)) << 2);
|
output->numClones + bytes_to_int32(rep.nameLength)) << 2);
|
||||||
|
|
||||||
if (extraLen) {
|
if (!extraLen)
|
||||||
rep.length += bytes_to_int32(extraLen);
|
goto sendout;
|
||||||
extra = calloc(1, extraLen);
|
|
||||||
if (!extra)
|
rep.length += bytes_to_int32(extraLen);
|
||||||
return BadAlloc;
|
extra = calloc(1, extraLen);
|
||||||
}
|
if (!extra)
|
||||||
|
return BadAlloc;
|
||||||
|
|
||||||
crtcs = (RRCrtc *) extra;
|
crtcs = (RRCrtc *) extra;
|
||||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||||
|
@ -516,6 +518,7 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
if (client->swapped)
|
if (client->swapped)
|
||||||
swapl(&crtcs[i]);
|
swapl(&crtcs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < output->numModes + output->numUserModes; i++) {
|
for (i = 0; i < output->numModes + output->numUserModes; i++) {
|
||||||
if (i < output->numModes)
|
if (i < output->numModes)
|
||||||
modes[i] = output->modes[i]->mode.id;
|
modes[i] = output->modes[i]->mode.id;
|
||||||
|
@ -531,6 +534,7 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendout:
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
|
@ -544,11 +548,10 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
swaps(&rep.nClones);
|
swaps(&rep.nClones);
|
||||||
swaps(&rep.nameLength);
|
swaps(&rep.nameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(xRRGetOutputInfoReply), &rep);
|
WriteToClient(client, sizeof(xRRGetOutputInfoReply), &rep);
|
||||||
if (extraLen) {
|
WriteToClient(client, extraLen, extra);
|
||||||
WriteToClient(client, extraLen, extra);
|
free(extra);
|
||||||
free(extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue