提交 9d0194b3 编写于 作者: B Behdad Esfahbod

[set] Optimize add_range() some more

It's as good as it gets, and seems to be on par with previous set implementation
in my benchmark.

Would be great if someone can double-check my bitops.
上级 438c325a
......@@ -67,9 +67,19 @@ struct hb_set_t
inline void add_range (hb_codepoint_t a, hb_codepoint_t b)
{
/* TODO Speed up. */
for (unsigned int i = a; i < b + 1; i++)
add (i);
elt_t *la = &elt (a);
elt_t *lb = &elt (b);
if (la == lb)
*la |= (mask (b) << 1) - mask(a);
else
{
*la |= ~(mask (a) - 1);
memset (la, 0xff, (char *) lb - (char *) la);
*lb |= ((mask (b) << 1) - 1);
}
}
inline bool is_equal (const page_t *other) const
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册