forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce string copies in GURL creation
Converts GURL's constructor to take StringPieces instead of std::string to avoid extra copies when converting from constants (which is fairly common). Adds a WebStringToGURL helper function. The above change broke the ability to give a WebString to GURL's constructor because that relied on the implicit string16 conversion on WebString which will no longer match GURL. This helper function will also eliminate a string copy for almost every WebString to GURL conversion. Normally if a WebString contains a URL, it will be ASCII. The old code would convert this ASCII to a temporary base::string16 just to pass into GURL, which can take either type (and will convert to 8-bit in the end either way). This exposes the internal 8- and 16-bit buffers via new getters. This allows the underlying buffers to be passed directly to GURL in the native format without copying. An alternative to exposing these getters would be to make the conversion function a friend, or adding a GURL getter directly on WebString. But this seems like the wrong type of function to have on a string class. There are a number of other modules in Chrome that can take either 8 or 16 bit strings that may be able to re-use this for performance-critical places. The mojo implicit string conversion was similarly broken. In these cases, this patch just adds a manual get() function call to retrieve the underlying std::string rather than relying on the implicit conversion. Media doesn't depend on content (where I put the helper function) and there were only a few WebString -> GURL conversions there, so I did an explicit string16 constructor for those (matching the current implicit behavior). Review URL: https://codereview.chromium.org/1568073002 Cr-Commit-Position: refs/heads/master@{#370274}
- Loading branch information
brettw
authored and
Commit bot
committed
Jan 20, 2016
1 parent
68f2329
commit dfbcc3b
Showing
63 changed files
with
243 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.