WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
177026
Allow WTF::map to use any class that is iterable and has a size getter
https://bugs.webkit.org/show_bug.cgi?id=177026
Summary
Allow WTF::map to use any class that is iterable and has a size getter
youenn fablet
Reported
2017-09-15 15:58:55 PDT
WTF::map could be for instance used to go from HashMap to Vector
Attachments
Patch
(10.08 KB, patch)
2017-09-15 17:21 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(10.16 KB, patch)
2017-09-18 08:43 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch for landing
(10.21 KB, patch)
2017-09-19 16:27 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
youenn fablet
Comment 1
2017-09-15 17:21:43 PDT
Created
attachment 320974
[details]
Patch
Build Bot
Comment 2
2017-09-15 17:24:33 PDT
Attachment 320974
[details]
did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:744: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:745: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:746: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:754: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:755: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:756: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:764: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:765: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:766: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] Total errors found: 9 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
youenn fablet
Comment 3
2017-09-15 18:12:21 PDT
Comment on
attachment 320974
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=320974&action=review
> Source/WebCore/loader/appcache/ApplicationCacheHost.cpp:334 > + return WTF::map(cache->resources(), [] (auto& urlAndResource) -> ApplicationCacheHost::ResourceInfo {
Will remove ApplicationCacheHost:: here.
Darin Adler
Comment 4
2017-09-16 08:43:19 PDT
Comment on
attachment 320974
[details]
Patch If the result type is always Vector, then we should probably name this something other than "map". Perhaps "mapToVector", which is less elegant, but still. I think we should consider basing this on std::begin, std::end, and std::size rather than on x.begin(), x.end(), and x.size(). However, std::size is C++17, so maybe we can’t rely on that.
http://en.cppreference.com/w/cpp/iterator/begin
http://en.cppreference.com/w/cpp/iterator/end
http://en.cppreference.com/w/cpp/iterator/size
youenn fablet
Comment 5
2017-09-17 17:40:53 PDT
> If the result type is always Vector, then we should probably name this > something other than "map". Perhaps "mapToVector", which is less elegant, > but still.
toVector might be shorter. Maybe this is just me, but map seems a big vague to me. There are various ways we could add further support of HashMap->HashMap, Vector->HashMap. I am not sure how much we would gain for these compared to usual for loops. For Vector, the gain is clear as we remove use of reserveInitialCapacity/uncheckedAppend.
> I think we should consider basing this on std::begin, std::end, and > std::size rather than on x.begin(), x.end(), and x.size(). However, > std::size is C++17, so maybe we can’t rely on that.
I'll switch to begin/end. For std::size, we might need to wait for mid 2008 for all compilers to support it.
youenn fablet
Comment 6
2017-09-18 08:43:57 PDT
Created
attachment 321094
[details]
Patch
Build Bot
Comment 7
2017-09-18 08:46:38 PDT
Attachment 321094
[details]
did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:744: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:745: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:746: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:754: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:755: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:756: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:764: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:765: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:766: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] Total errors found: 9 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 8
2017-09-18 11:52:13 PDT
Comment on
attachment 321094
[details]
Patch Clearing flags on attachment: 321094 Committed
r222170
: <
http://trac.webkit.org/changeset/222170
>
WebKit Commit Bot
Comment 9
2017-09-18 11:52:15 PDT
All reviewed patches have been landed. Closing bug.
Ryan Haddad
Comment 10
2017-09-18 13:55:01 PDT
(In reply to WebKit Commit Bot from
comment #8
)
> Comment on
attachment 321094
[details]
> Patch > > Clearing flags on attachment: 321094 > > Committed
r222170
: <
http://trac.webkit.org/changeset/222170
>
The API test added with this change is failing on the bots: FAIL WTF_Vector.MapFromHashMap /Volumes/Data/slave/sierra-release/build/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:768 Value of: map.contains("k1") Actual: false Expected: true /Volumes/Data/slave/sierra-release/build/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:769 Value of: map.contains("k2") Actual: false Expected: true /Volumes/Data/slave/sierra-release/build/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:770 Value of: map.contains("k3") Actual: false Expected: true
https://build.webkit.org/builders/Apple%20Sierra%20Release%20WK2%20(Tests)/builds/4365
Ryan Haddad
Comment 11
2017-09-18 14:05:03 PDT
Reverted
r222170
for reason: The API test added with this change is failing. Committed
r222180
: <
http://trac.webkit.org/changeset/222180
>
youenn fablet
Comment 12
2017-09-19 16:27:29 PDT
Created
attachment 321263
[details]
Patch for landing
Build Bot
Comment 13
2017-09-19 16:29:40 PDT
Attachment 321263
[details]
did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:744: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:745: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:746: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:754: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:755: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:756: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:764: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:765: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:766: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] Total errors found: 9 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 14
2017-09-19 17:57:44 PDT
Comment on
attachment 321263
[details]
Patch for landing Clearing flags on attachment: 321263 Committed
r222238
: <
http://trac.webkit.org/changeset/222238
>
WebKit Commit Bot
Comment 15
2017-09-19 17:57:46 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 16
2017-09-27 12:27:05 PDT
<
rdar://problem/34693300
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug