[Webkit-unassigned] [Bug 188501] Meaning of OptionSet::contains is unclear when used with OptionSet argument

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 13 09:10:17 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=188501

Said Abou-Hallawa <sabouhallawa at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sabouhallawa at apple.com

--- Comment #3 from Said Abou-Hallawa <sabouhallawa at apple.com> ---
Comment on attachment 347002
  --> https://bugs.webkit.org/attachment.cgi?id=347002
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=347002&action=review

> Source/WTF/ChangeLog:8
> +        The existing behavior is "contains any" but it is not very clear from the name.

I think contains() should act like containsAll(). When I say

    options1.contains(options2)

I would expect this expression to be evaluated to true if and only if "all" the bits of options2 are also in options1.

> Source/WTF/wtf/OptionSet.h:107
> +    constexpr bool containsAny(OptionSet optionSet) const
> +    {
> +        return !!(*this & optionSet);
> +    }

I do not think this is needed. The bitwise & operator overloading can do exactly what this function does. When I say

    if (option1 & options2)

The result of the expression "option1 & options2" is an OptionSet which contains option1.m_storage & option1.m_storage. The bool cast operator will check isEmpty of the the result OptionSet.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180813/3b2b29d3/attachment.html>


More information about the webkit-unassigned mailing list