Bug 142429 - Merge TrivialAtom and CharacterSet into a Term abstraction, prepare Term for composition
Summary: Merge TrivialAtom and CharacterSet into a Term abstraction, prepare Term for ...
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: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-06 20:47 PST by Benjamin Poulain
Modified: 2015-03-09 14:13 PDT (History)
3 users (show)

See Also:


Attachments
Patch (33.37 KB, patch)
2015-03-06 20:53 PST, Benjamin Poulain
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2015-03-06 20:47:04 PST
Merge TrivialAtom and CharacterSet into a Term abstraction, prepare Term for composition
Comment 1 Benjamin Poulain 2015-03-06 20:53:17 PST
Created attachment 248139 [details]
Patch
Comment 2 WebKit Commit Bot 2015-03-06 20:55:02 PST
Attachment 248139 [details] did not pass style-queue:


ERROR: Source/WebCore/contentextensions/URLFilterParser.cpp:487:  Place brace on its own line for function definitions.  [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 2015-03-07 09:24:33 PST
Comment on attachment 248139 [details]
Patch

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

> Source/WebCore/contentextensions/URLFilterParser.cpp:51
> +    enum class TermType : uint8_t {
> +        Empty,
> +        Deleted,
> +        CharacterSet
> +    };

This private enum can be in the private: section. There’s no need to have it at the top of the class.

> Source/WebCore/contentextensions/URLFilterParser.cpp:55
> +    Term()
> +    {
> +    }

Why are all the function bodies in the class? To me this seems to make the class harder to read.

> Source/WebCore/contentextensions/URLFilterParser.cpp:281
> +        ~AtomData()
> +        {
> +        }

Is this explicit definition of the destructor needed? If so, why?
Comment 4 Alex Christensen 2015-03-09 14:06:01 PDT
Comment on attachment 248139 [details]
Patch

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

> Source/WebCore/contentextensions/URLFilterParser.cpp:261
> +        BitVector characters { 128 };

If I understand this correctly, the whole point of using a union, placement new, and explicitly calling destructors is to avoid allocating and deallocating a BitVector for empty/deleted slots in a hash table.  Won't this all be excessive if we switch to using two uint64_t's?
Comment 5 Benjamin Poulain 2015-03-09 14:07:44 PDT
Committed r181282: <http://trac.webkit.org/changeset/181282>
Comment 6 Benjamin Poulain 2015-03-09 14:08:46 PDT
(In reply to comment #4)
> Comment on attachment 248139 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=248139&action=review
> 
> > Source/WebCore/contentextensions/URLFilterParser.cpp:261
> > +        BitVector characters { 128 };
> 
> If I understand this correctly, the whole point of using a union, placement
> new, and explicitly calling destructors is to avoid allocating and
> deallocating a BitVector for empty/deleted slots in a hash table.  Won't
> this all be excessive if we switch to using two uint64_t's?

The union is there to support other terms without rewriting everything.
Comment 7 Benjamin Poulain 2015-03-09 14:13:37 PDT
(In reply to comment #3)
> Comment on attachment 248139 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=248139&action=review
> 
> > Source/WebCore/contentextensions/URLFilterParser.cpp:51
> > +    enum class TermType : uint8_t {
> > +        Empty,
> > +        Deleted,
> > +        CharacterSet
> > +    };
> 
> This private enum can be in the private: section. There’s no need to have it
> at the top of the class.

IIRC, some compiler complained about it when it was at the end of the file. Clang seems fine with it, let's try again.

> > Source/WebCore/contentextensions/URLFilterParser.cpp:55
> > +    Term()
> > +    {
> > +    }
> 
> Why are all the function bodies in the class? To me this seems to make the
> class harder to read.

JavaScriptCore users that style for private generators so I copied that here.

> > Source/WebCore/contentextensions/URLFilterParser.cpp:281
> > +        ~AtomData()
> > +        {
> > +        }
> 
> Is this explicit definition of the destructor needed? If so, why?

It is. The union has non trivial destructor so they need to be invoked explicitly. In this case, the destructor ignore the cleanup and the destroy() function takes care of it.