Bug 121192 - Add HashSet::take
Summary: Add HashSet::take
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-11 16:58 PDT by Anders Carlsson
Modified: 2013-09-11 17:30 PDT (History)
4 users (show)

See Also:


Attachments
Patch (3.72 KB, patch)
2013-09-11 17:11 PDT, Anders Carlsson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Carlsson 2013-09-11 16:58:27 PDT
Add HashSet::take
Comment 1 Anders Carlsson 2013-09-11 17:11:01 PDT
Created attachment 211367 [details]
Patch
Comment 2 WebKit Commit Bot 2013-09-11 17:14:49 PDT
Attachment 211367 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WTF/ChangeLog', u'Source/WTF/wtf/HashMap.h', u'Source/WTF/wtf/HashSet.h', u'Tools/ChangeLog', u'Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp']" exit_code: 1
Source/WTF/wtf/HashSet.h:239:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2013-09-11 17:17:09 PDT
Comment on attachment 211367 [details]
Patch

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

In a recent patch I was working on, it was ListHashSet::take that I needed.

> Source/WTF/wtf/HashSet.h:238
> +    auto HashSet<T, U, V>::take(const ValueType& value) -> ValueType

This works in all the compilers we support?
Comment 4 Darin Adler 2013-09-11 17:18:24 PDT
(In reply to comment #3)
> In a recent patch I was working on, it was ListHashSet::take that I needed.

No, wait, it was HashSet::take, because I wanted to take an element out of a set; I always took the one at begin().
Comment 5 Anders Carlsson 2013-09-11 17:21:53 PDT
(In reply to comment #3)
> This works in all the compilers we support?

I think so, it was added in VS2010 and GCC 4.4 (and clang 2.9).

(In reply to comment #4)
> (In reply to comment #3)
> > In a recent patch I was working on, it was ListHashSet::take that I needed.
> 
> No, wait, it was HashSet::take, because I wanted to take an element out of a set; I always took the one at begin().

That makes me think we should add a take(iterator) overload as well.
Comment 6 Darin Adler 2013-09-11 17:24:25 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > No, wait, it was HashSet::take, because I wanted to take an element out of a set; I always took the one at begin().
> 
> That makes me think we should add a take(iterator) overload as well.

It was a security bug, bug 121033, if you want to look.
Comment 7 Darin Adler 2013-09-11 17:25:48 PDT
It might be nice to have s.takeRandom() or s.takeAny() rather than s.take(s.begin()).
Comment 8 Anders Carlsson 2013-09-11 17:30:07 PDT
Committed r155580: <http://trac.webkit.org/changeset/155580>