WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
178169
It should be possible to iterate just the values (and not the counts) of a HashCountedSet
https://bugs.webkit.org/show_bug.cgi?id=178169
Summary
It should be possible to iterate just the values (and not the counts) of a Ha...
Sam Weinig
Reported
2017-10-11 07:38:37 PDT
It should be possible to iterate just the values (and not the counts) of a HashCountedSet
Attachments
Patch
(25.05 KB, patch)
2017-10-11 07:49 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2017-10-11 07:49:24 PDT
Created
attachment 323415
[details]
Patch
Build Bot
Comment 2
2017-10-11 07:50:47 PDT
Attachment 323415
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/HashCountedSet.h:135: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/WTF/wtf/HashCountedSet.h:170: This { should be at the end of the previous line [whitespace/braces] [4] ERROR: Source/WTF/wtf/HashCountedSet.h:279: This { should be at the end of the previous line [whitespace/braces] [4] ERROR: Source/WTF/wtf/HashCountedSet.h:286: This { should be at the end of the previous line [whitespace/braces] [4] ERROR: Source/WTF/wtf/HashCountedSet.h:293: This { should be at the end of the previous line [whitespace/braces] [4] ERROR: Source/WTF/wtf/HashCountedSet.h:300: This { should be at the end of the previous line [whitespace/braces] [4] ERROR: Source/WTF/wtf/HashCountedSet.h:307: This { should be at the end of the previous line [whitespace/braces] [4] Total errors found: 7 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Daniel Bates
Comment 3
2017-10-11 23:32:30 PDT
Comment on
attachment 323415
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=323415&action=review
> Source/WTF/wtf/HashCountedSet.h:43 > + HashCountedSet()
HashCountedSet() = default;
> Source/WTF/wtf/HashCountedSet.h:103 > + template<typename V = ValueType> typename std::enable_if<IsSmartPtr<V>::value, iterator>::type find(typename GetPtrHelper<V>::PtrType);
We should use enable_if_t<> to simplify this.
> Source/WTF/wtf/HashCountedSet.h:104 > + template<typename V = ValueType> typename std::enable_if<IsSmartPtr<V>::value, const_iterator>::type find(typename GetPtrHelper<V>::PtrType) const;
Ditto.
> Source/WTF/wtf/HashCountedSet.h:105 > + template<typename V = ValueType> typename std::enable_if<IsSmartPtr<V>::value, bool>::type contains(typename GetPtrHelper<V>::PtrType) const;
Ditto.
> Source/WTF/wtf/HashCountedSet.h:106 > + template<typename V = ValueType> typename std::enable_if<IsSmartPtr<V>::value, unsigned>::type count(typename GetPtrHelper<V>::PtrType) const;
Ditto.
> Source/WTF/wtf/HashCountedSet.h:107 > + template<typename V = ValueType> typename std::enable_if<IsSmartPtr<V>::value, bool>::type remove(typename GetPtrHelper<V>::PtrType);
Ditto.
> Source/WTF/wtf/HashCountedSet.h:242 > + unsigned oldVal = it->value;
oldVal => oldValue
> Source/WTF/wtf/HashCountedSet.h:244 > + unsigned newVal = oldVal - 1;
newVal => newValue
> Source/WTF/wtf/HashCountedSet.h:278 > +inline auto HashCountedSet<Value, HashFunctions, Traits>::find(typename GetPtrHelper<V>::PtrType value) -> typename std::enable_if<IsSmartPtr<V>::value, iterator>::type
We should use enable_if_t<> to simply this.
> Source/WTF/wtf/HashCountedSet.h:285 > +inline auto HashCountedSet<Value, HashFunctions, Traits>::find(typename GetPtrHelper<V>::PtrType value) const -> typename std::enable_if<IsSmartPtr<V>::value, const_iterator>::type
Ditto.
> Source/WTF/wtf/HashCountedSet.h:292 > +inline auto HashCountedSet<Value, HashFunctions, Traits>::contains(typename GetPtrHelper<V>::PtrType value) const -> typename std::enable_if<IsSmartPtr<V>::value, bool>::type
Ditto.
> Source/WTF/wtf/HashCountedSet.h:299 > +inline auto HashCountedSet<Value, HashFunctions, Traits>::count(typename GetPtrHelper<V>::PtrType value) const -> typename std::enable_if<IsSmartPtr<V>::value, unsigned>::type
Ditto.
> Source/WTF/wtf/HashCountedSet.h:306 > +inline auto HashCountedSet<Value, HashFunctions, Traits>::remove(typename GetPtrHelper<V>::PtrType value) -> typename std::enable_if<IsSmartPtr<V>::value, bool>::type
Ditto.
> Source/WTF/wtf/HashCountedSet.h:314 > + typedef typename HashCountedSet<Value, HashFunctions, Traits>::const_iterator iterator;
using ... = ...;
> Source/WTF/wtf/HashCountedSet.h:327 > + typedef typename HashCountedSet<Value, HashFunctions, Traits>::const_iterator iterator;
Ditto.
> Source/WTF/wtf/HashCountedSet.h:333 > + for (unsigned i = 0; it != end; ++it, ++i)
size_t
> Tools/TestWebKitAPI/Tests/WTF/HashCountedSet.cpp:474 > + HashCountedSet<int> set { 1, 1, 2, 3, 3 };
You might want to consider adding more test coverage. Say, test the empty set, a set with exactly one value, a set with exactly two repeated values. Having said that the implementation of values() is just to turn around and call keys() and I would hope we have existing test coverage for this.
Daniel Bates
Comment 4
2017-10-11 23:36:21 PDT
(In reply to Daniel Bates from
comment #3
)
> > Source/WTF/wtf/HashCountedSet.h:333 > > + for (unsigned i = 0; it != end; ++it, ++i) > > size_t >
I know unsigned is good enough for all practical purposes. I still prefer size_t because it avoids an implicit conversion when calling operator[] and that makes me feel warm and fuzzy.
Sam Weinig
Comment 5
2017-10-12 05:18:12 PDT
Comment on
attachment 323415
[details]
Patch Thanks for the review Dan! I'll address the comments in a follow up that cleans up additional Hash related files.
WebKit Commit Bot
Comment 6
2017-10-12 05:46:00 PDT
Comment on
attachment 323415
[details]
Patch Clearing flags on attachment: 323415 Committed
r223236
: <
https://trac.webkit.org/changeset/223236
>
WebKit Commit Bot
Comment 7
2017-10-12 05:46:02 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 8
2017-10-12 05:47:07 PDT
<
rdar://problem/34954222
>
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