Skip to content

Commit f323f1e

Browse files
committed
LogMatrix: minor performance improvement for fwrite
1 parent 519b005 commit f323f1e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

core/src/LogMatrix.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class LogMatrix
4444
// Write pixels
4545
for (int y = 0; y < _log.height(); ++y)
4646
for (int x = 0; x < _log.width(); ++x) {
47-
unsigned char r, g, b;
47+
unsigned char pix[3];
48+
unsigned char &r = pix[0], &g = pix[1], &b = pix[2];
4849
r = g = b = _image->get(x / _scale, y / _scale) ? 0 : 255;
4950
if (_scale > 1 && x % _scale == _scale / 2 && y % _scale == _scale / 2)
5051
r = g = b = r ? 230 : 50;
@@ -54,9 +55,7 @@ class LogMatrix
5455
case 3: g = r = 100, b = 250; break;
5556
case 4: g = b = 100, r = 250; break;
5657
}
57-
fwrite(&r, 1, 1, f);
58-
fwrite(&g, 1, 1, f);
59-
fwrite(&b, 1, 1, f);
58+
fwrite(&pix, 3, 1, f);
6059
}
6160
fclose(f);
6261
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy