Some minor performance tweaks

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@726 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-09-21 11:55:54 +00:00
parent f60e929d78
commit 29c9f9ae8d
2 changed files with 46 additions and 9 deletions
+10 -5
View File
@@ -62,10 +62,15 @@ void fill_image(Image& image, const Color& color) {
Byte* pos = image.GetData();
Byte* end = pos + image.GetWidth() * image.GetHeight() * 3;
Byte r = color.Red(), g = color.Green(), b = color.Blue();
// fill the image
while (pos != end) {
*pos++ = r;
*pos++ = g;
*pos++ = b;
if (r == g && r == b) {
// optimization: use memset
memset(pos, r, end-pos);
} else {
// fill the image
while (pos != end) {
*pos++ = r;
*pos++ = g;
*pos++ = b;
}
}
}