[webkit-reviews] review granted: [Bug 178169] It should be possible to iterate just the values (and not the counts) of a HashCountedSet : [Attachment 323415] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Oct 11 23:32:30 PDT 2017


Daniel Bates <dbates at webkit.org> has granted Sam Weinig <sam at webkit.org>'s
request for review:
Bug 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

Attachment 323415: Patch

https://bugs.webkit.org/attachment.cgi?id=323415&action=review




--- Comment #3 from Daniel Bates <dbates at webkit.org> ---
Comment on attachment 323415
  --> https://bugs.webkit.org/attachment.cgi?id=323415
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.


More information about the webkit-reviews mailing list