[cairo] On _cairo_path_buf_fixed
Behdad Esfahbod
behdad at behdad.org
Fri May 9 13:55:05 PDT 2008
Chris,
In the following struct:
typedef struct _cairo_path_buf_fixed {
cairo_path_buf_t base;
cairo_path_op_t op[CAIRO_PATH_BUF_SIZE];
cairo_point_t points[2 * CAIRO_PATH_BUF_SIZE];
} cairo_path_buf_fixed_t;
Any reason to have the points array twice longer than the ops? Each
point is 8 bytes while each op is 1 byte. Each line_to and move_to op
have one point, while each curve_to has 3. If we get no curve_to, we
leave half of the point array empty, while if it's all curves, one third
of the ops array is left empty. That is, max waste is 4/9th of total
space. We're much better off running out of space in the points array
rather than in ops. If we have equal size arrays, max waste is when
having all curves, which would be only 2/9th of total space.
--
behdad
http://behdad.org/
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
More information about the cairo
mailing list