WebKit Bugzilla
Attachment 349946 Details for
Bug 189633
: Add count() function to OptionSet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189633-20180917150450.patch (text/plain), 3.16 KB, created by
Woodrow Wang
on 2018-09-17 15:04:51 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Woodrow Wang
Created:
2018-09-17 15:04:51 PDT
Size:
3.16 KB
patch
obsolete
>Subversion Revision: 236084 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index ef794f8f358aa9d6679f2a9fb0fbbec79a68a4d0..e2ace498193008ee20aa1d824d7f47904a4561f4 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,14 @@ >+2018-09-17 Woodrow Wang <woodrow_wang@apple.com> >+ >+ Add size() function to OptionSet >+ https://bugs.webkit.org/show_bug.cgi?id=189633 >+ <rdar://problem/44469944> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/OptionSet.h: >+ (WTF::OptionSet::size): >+ > 2018-09-17 Jer Noble <jer.noble@apple.com> > > Enable USE_MEDIAREMOTE on iOS >diff --git a/Source/WTF/wtf/OptionSet.h b/Source/WTF/wtf/OptionSet.h >index f18ff2c9ff6f1fd09bef2443f082223f5ab24c7d..c1312c342851eb59457e477c94c3d51faa497775 100644 >--- a/Source/WTF/wtf/OptionSet.h >+++ b/Source/WTF/wtf/OptionSet.h >@@ -121,6 +121,21 @@ public: > m_storage &= ~optionSet.m_storage; > } > >+ constexpr unsigned size() >+ { >+#if COMPILER(GCC_OR_CLANG) >+ static_assert(sizeof(StorageType) <= sizeof(unsigned long long), "__builtin_popcount is not supported for the underlying OptionSet storage type."); >+ return __builtin_popcountll(static_cast<unsigned long long>(m_storage)); >+#else >+ unsigned numberOfSetBits = 0; >+ for (auto unusedValue : *this) { >+ UNUSED_PARAM(unusedValue); >+ ++numberOfSetBits; >+ } >+ return numberOfSetBits; >+#endif >+ } >+ > constexpr friend bool operator==(OptionSet lhs, OptionSet rhs) > { > return lhs.m_storage == rhs.m_storage; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 019c074db29c042f756c3b25b03124b2956488d2..350ec067af31f15a996edd11947ec39348622da7 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,16 @@ >+2018-09-17 Woodrow Wang <woodrow_wang@apple.com> >+ >+ Add size() function to OptionSet >+ https://bugs.webkit.org/show_bug.cgi?id=189633 >+ <rdar://problem/44469944> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a test for new size() function. >+ >+ * TestWebKitAPI/Tests/WTF/OptionSet.cpp: >+ (TestWebKitAPI::TEST): >+ > 2018-08-31 Woodrow Wang <woodrow_wang@apple.com> > > Add infrastructure to dump resource load statistics >diff --git a/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp b/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp >index 493ec25c06f569cd5439c401f82654cf7b7c2b9b..acbde2d4deae4681a20208831a2885ea49db97ed 100644 >--- a/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp >+++ b/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp >@@ -436,4 +436,23 @@ TEST(WTF_OptionSet, ContainsAll) > EXPECT_FALSE(set.containsAll({ ExampleFlags::A, ExampleFlags::B, ExampleFlags::C })); > } > >+TEST(WTF_OptionSet, Size) >+{ >+ OptionSet<ExampleFlags> set; >+ >+ EXPECT_EQ(set.size(), 0U); >+ set.add(ExampleFlags::A); >+ EXPECT_EQ(set.size(), 1U); >+ set.remove(ExampleFlags::A); >+ set.add(ExampleFlags::B); >+ EXPECT_EQ(set.size(), 1U); >+ set.remove(ExampleFlags::B); >+ set.add(ExampleFlags::E); >+ EXPECT_EQ(set.size(), 1U); >+ set.add(ExampleFlags::A); >+ EXPECT_EQ(set.size(), 2U); >+ set.add(ExampleFlags::C); >+ EXPECT_EQ(set.size(), 3U); >+} >+ > } // namespace TestWebKitAPI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189633
:
349941
|
349946
|
349975
|
349978
|
350056
|
350081
|
350086
|
350134
|
350150
|
350281