Re: [AD] optimization of create_video_bitmap() |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> The attached patch optimizes create_video_bitmap().
Looks mostly good to me, except:
+/* the product of these must fit in an int */
+static int _create_video_bitmap_failed_w = 46340;
+static int _create_video_bitmap_failed_h = 46340;
Ah! Magic numbers... A #define would certainly be better here.
+ if (width * height >
+ _create_video_bitmap_failed_w * _create_video_bitmap_failed_h) {
+ _create_video_bitmap_failed_w = width;
+ _create_video_bitmap_failed_h = height;
+ }
It looks like your caching mechanism won't actually cache many things ;-)
+ _create_video_bitmap_failed_w =
+ _create_video_bitmap_failed_w * 2 + ((bitmap->w + 15) & ~15);
+ if (_create_video_bitmap_failed_w > 46340)
+ _create_video_bitmap_failed_w = 46340;
+ _create_video_bitmap_failed_h =
+ _create_video_bitmap_failed_h * 2 + bitmap->h;
+ if (_create_video_bitmap_failed_w > 46340)
+ _create_video_bitmap_failed_w = 46340;
Ah! Copy-and-paste... Very useful but very dangerous as well ;-)
--
Eric Botcazou
ebotcazou@xxxxxxxxxx