[webkit-reviews] review granted: [Bug 211328] Allow Bitmap to use up to a UCPURegister word size for internal bit storage. : [Attachment 398272] proposed patch.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri May 1 20:03:00 PDT 2020
Yusuke Suzuki <ysuzuki at apple.com> has granted Mark Lam <mark.lam at apple.com>'s
request for review:
Bug 211328: Allow Bitmap to use up to a UCPURegister word size for internal bit
storage.
https://bugs.webkit.org/show_bug.cgi?id=211328
Attachment 398272: proposed patch.
https://bugs.webkit.org/attachment.cgi?id=398272&action=review
--- Comment #5 from Yusuke Suzuki <ysuzuki at apple.com> ---
Comment on attachment 398272
--> https://bugs.webkit.org/attachment.cgi?id=398272
proposed patch.
View in context: https://bugs.webkit.org/attachment.cgi?id=398272&action=review
r=me
> Source/WTF/wtf/Bitmap.h:51
> +template<size_t size, typename = std::true_type>
> +struct BitmapWordType {
> + using type = UCPURegister;
> +};
> +
> +template<size_t size>
> +struct BitmapWordType<size, std::enable_if_t<(size <= 8), std::true_type>> {
> + using type = uint8_t;
> +};
> +
> +template<size_t size>
> +struct BitmapWordType<size, std::enable_if_t<(size > 8 && size <= 16),
std::true_type>> {
> + using type = uint16_t;
> +};
> +
> +template<size_t size>
> +struct BitmapWordType<size, std::enable_if_t<(size > 16 && size <= 32 &&
sizeof(UCPURegister) > sizeof(uint32_t)), std::true_type>> {
> + using type = uint32_t;
> +};
> +
> +template<size_t bitmapSize, typename WordType = typename
BitmapWordType<bitmapSize>::type>
You can use std::conditional<>.
template<size_t size>
using BitmapWordType = std::conditional_t<size <= 8,
uint8_t,
std::conditional_t<size <= 16,
uint16_t,
std::conditional_t<size <= 32 && sizeof(UCPURegister) >
sizeof(uint32_t),
uint32_t,
UCPURegister>>>;
And,
template<size_t bitmapSize, typename WordType = BitmapWordType<bitmapSize>>
More information about the webkit-reviews
mailing list