WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
164952
Use Vector::uncheckedAppend() in more places
https://bugs.webkit.org/show_bug.cgi?id=164952
Summary
Use Vector::uncheckedAppend() in more places
Daniel Bates
Reported
2016-11-18 13:46:36 PST
We can use Vector::uncheckedAppend() whenever the number of items that will be appended to a vector is equal to or less than its capacity. Many call sites that call Vector::reserveInitialCapacity() and then use Vector::append() can be written to use Vector::uncheckedAppend().
Attachments
Patch
(14.05 KB, patch)
2016-11-18 13:47 PST
,
Daniel Bates
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Daniel Bates
Comment 1
2016-11-18 13:47:59 PST
Created
attachment 295187
[details]
Patch
Darin Adler
Comment 2
2016-11-20 16:29:59 PST
Comment on
attachment 295187
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=295187&action=review
> Source/WebCore/contentextensions/DFAMinimizer.cpp:90 > + m_sets.uncheckedAppend(SetDescriptor({ 0, size, 0 }));
Peculiar that we reserve capacity for "size" elements, but here we do only a single uncheckedAppend. Did we reserve too much capacity? Syntax is peculiar; I think it should just be: m_sets.uncheckedAppend(SetDescriptor { 0, size, 0 }); No need to have both parentheses and braces.
Daniel Bates
Comment 3
2016-12-06 09:39:30 PST
(In reply to
comment #2
)
> Comment on
attachment 295187
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=295187&action=review
> > > Source/WebCore/contentextensions/DFAMinimizer.cpp:90 > > + m_sets.uncheckedAppend(SetDescriptor({ 0, size, 0 })); > > Peculiar that we reserve capacity for "size" elements, but here we do only a > single uncheckedAppend. Did we reserve too much capacity? >
We may have reserved too much though it is not immediately obvious from reading the code. I hope you do not mind that I defer proving the bound of m_set to
bug #165472
.
> Syntax is peculiar; I think it should just be: > > m_sets.uncheckedAppend(SetDescriptor { 0, size, 0 }); > > No need to have both parentheses and braces.
Will fix before landing.
Daniel Bates
Comment 4
2016-12-06 09:43:10 PST
Committed
r209400
: <
http://trac.webkit.org/changeset/209400
>
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