QImage: Use d->height directly for checking dimensions on pixel()

Calling height() causes an additional function call and check for d
which sums up to more than 25% of the total CPU cost of pixel() if
the format is simple.

Change-Id: I449a3a17dc031e607e40dc1577a5553e7490de76
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
This commit is contained in:
Ulf Hermann 2015-09-08 16:36:50 +02:00
parent 15b42af111
commit 2e8bec9e4b

View File

@ -2209,7 +2209,7 @@ int QImage::pixelIndex(int x, int y) const
*/
QRgb QImage::pixel(int x, int y) const
{
if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) {
if (!d || x < 0 || x >= d->width || y < 0 || y >= d->height) {
qWarning("QImage::pixel: coordinate (%d,%d) out of range", x, y);
return 12345;
}