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

Issue 1411413008: Short-circuit Uri._uriEncode for components that don't need encoding. (Closed)

Created:
5 years, 1 month ago by sra1
Modified:
5 years, 1 month ago
CC:
reviews_dartlang.org, Siggi Cherem (dart-lang), floitsch
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Short-circuit Uri._uriEncode for components that don't need encoding. For dart2js: Uri.pathSegments.easy: +792% Uri.pathSegments.hard.escaped: +8% Uri.pathSegments.hard.normalized: +152% For VM: Uri.pathSegments.easy: +117% Uri.pathSegments.hard.escaped: -8% Uri.pathSegments.hard.normalized: +35% We could probably get a little more in the browser if we make the check a patched '_platformUriEncode' method, but the 'encoding' parameter makes it impossible to remove _uriEncode completely. R=lrn@google.com Committed: https://github.com/dart-lang/sdk/commit/6ddbaa55a4bab95baf49ea54b5d50d85a4995dcf

Patch Set 1 : #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+6 lines, -0 lines) Patch
M sdk/lib/core/uri.dart View 2 chunks +6 lines, -0 lines 4 comments Download

Messages

Total messages: 18 (6 generated)
sra1
5 years, 1 month ago (2015-11-03 03:55:30 UTC) #6
Lasse Reichstein Nielsen
I would rather avoid using a RegExp as part of the parser. Instead it should ...
5 years, 1 month ago (2015-11-03 06:53:12 UTC) #7
Lasse Reichstein Nielsen
Another thing we can do is to special-case the entire function for the most common ...
5 years, 1 month ago (2015-11-03 07:08:20 UTC) #8
Lasse Reichstein Nielsen
For a different approach, please try comparing with: https://codereview.chromium.org/1425373005
5 years, 1 month ago (2015-11-03 07:08:49 UTC) #9
Lasse Reichstein Nielsen
https://codereview.chromium.org/1411413008/diff/60001/sdk/lib/core/uri.dart File sdk/lib/core/uri.dart (right): https://codereview.chromium.org/1411413008/diff/60001/sdk/lib/core/uri.dart#newcode2267 sdk/lib/core/uri.dart:2267: if (_needsNoEncoding.hasMatch(text)) return text; Ah, finally realized that the ...
5 years, 1 month ago (2015-11-03 07:12:08 UTC) #10
Lasse Reichstein Nielsen
For even more optimization, please compare with https://codereview.chromium.org/1409053007 as well.
5 years, 1 month ago (2015-11-03 10:24:25 UTC) #11
sra1
This CL adds 461 bytes and gives 8x on the common easy case. The first ...
5 years, 1 month ago (2015-11-03 19:00:57 UTC) #12
Lasse Reichstein Nielsen
On 2015/11/03 19:00:57, sra1 wrote: > This CL adds 461 bytes and gives 8x on ...
5 years, 1 month ago (2015-11-03 20:12:35 UTC) #13
sra1
Committed patchset #1 (id:60001) manually as 6ddbaa55a4bab95baf49ea54b5d50d85a4995dcf (presubmit successful).
5 years, 1 month ago (2015-11-03 22:16:27 UTC) #14
Ivan Posva
Please provide a non-regexp solution. Thanks, -Ivan https://codereview.chromium.org/1411413008/diff/60001/sdk/lib/core/uri.dart File sdk/lib/core/uri.dart (right): https://codereview.chromium.org/1411413008/diff/60001/sdk/lib/core/uri.dart#newcode2256 sdk/lib/core/uri.dart:2256: static final ...
5 years, 1 month ago (2015-11-04 05:11:50 UTC) #16
sra1
Lasse: considering Ivan's comment, can you set up platform patches?
5 years, 1 month ago (2015-11-04 07:52:59 UTC) #17
Lasse Reichstein Nielsen
5 years, 1 month ago (2015-11-04 08:32:41 UTC) #18
Message was sent while issue was closed.
Yes, will do.

https://codereview.chromium.org/1411413008/diff/60001/sdk/lib/core/uri.dart
File sdk/lib/core/uri.dart (right):

https://codereview.chromium.org/1411413008/diff/60001/sdk/lib/core/uri.dart#n...
sdk/lib/core/uri.dart:2267: if (_needsNoEncoding.hasMatch(text)) return text;
Only do this if encoding is UTF8, LATIN1 or ASCII (or even only if it's UTF8
since that's the common case). 
Otherwise we don't know that an "A" is encoded as 0x41. I doubt we'll have
EBCDIC encoding (letters are above 128), but to be fair, we should allow for it.

It's too late to remove the encoding argument (if we want to reuse the function,
at least, there is only one call that actually passed the encoding).

If the optional parameters cause extra code, just make them non-optional. We can
call with ..., UTF8, false) in the places where the parameter is not passed.

Powered by Google App Engine
This is Rietveld 408576698