Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Issue 11299163: Optimize non-ASCII string splitting with single-character search pattern (Closed)

Created:
8 years, 1 month ago by bnoordhuis1
Modified:
8 years ago
CC:
v8-dev
Visibility:
Public.

Description

Optimize non-ASCII string splitting with single-character search pattern Committed: https://code.google.com/p/v8/source/detail?r=13119

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+57 lines, -7 lines) Patch
M src/objects.h View 1 chunk +7 lines, -0 lines 1 comment Download
M src/runtime.cc View 2 chunks +33 lines, -7 lines 1 comment Download
M test/mjsunit/string-split.js View 1 chunk +17 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
bnoordhuis1
string: optimize non-ASCII string splitting Optimize String.split() for UCS-2 strings where the search pattern is ...
8 years, 1 month ago (2012-11-23 22:38:59 UTC) #1
Yang
Thanks for this patch! I have some drive-by comments. https://codereview.chromium.org/11299163/diff/1/src/objects.h File src/objects.h (right): https://codereview.chromium.org/11299163/diff/1/src/objects.h#newcode7195 src/objects.h:7195: ...
8 years ago (2012-11-26 08:45:30 UTC) #2
Yang
8 years ago (2012-12-03 16:47:32 UTC) #3
On 2012/11/26 08:45:30, Yang wrote:
> Thanks for this patch! I have some drive-by comments.
> 
> https://codereview.chromium.org/11299163/diff/1/src/objects.h
> File src/objects.h (right):
> 
> https://codereview.chromium.org/11299163/diff/1/src/objects.h#newcode7195
> src/objects.h:7195: if (state_ == TWO_BYTE) return buffer_.length() / 2;
> you could do an
> if (state_ == ASCII) {
>   ...
> } else {
>   ASSERT(state == TWO_BYTE) {
>   ...
> }
> 
> to be cleaner.
> 
> Even cooler would be without any branching, like,
> 
> ASSERT(ASCII == 0 && TWO_BYTE == 1);
> ASSERT(state_ == ASCII || state_ == TWO_BYTE);
> return buffer_.length() >> state_;
> 
> (Make sure the enum elements have values explicitly assigned.)
> 
> https://codereview.chromium.org/11299163/diff/1/src/runtime.cc
> File src/runtime.cc (right):
> 
> https://codereview.chromium.org/11299163/diff/1/src/runtime.cc#newcode2860
> src/runtime.cc:2860: zone);
> Since we are doing the IsAscii() check (implied in Length()) in any case,
> couldn't we leave it with
> 
> if (pattern_content.IsAscii()) {
>   Vector<const char> pattern_vector = pattern_content.ToAsciiVector();
>   if (pattern_vector.length() == 1) {
>     ...
>   } else {
>     ...
>   }
> } else {
>   Vector<const uc16> pattern_vector = pattern_content.ToUC16Vector();
>   if (pattern_vector.length() == 1) {
>     ...
>   } else {
>     ...
>   }
> }
> 
> I know this is a bit more verbose, but this way we don't have to introduce
> Length() and also avoid the redundant ascii check.

LGTM. I'll just land this CL with my suggested changes. :)

Powered by Google App Engine
This is Rietveld 408576698