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

Unified Diff: src/uri.js

Issue 164396: Move some arrays into functions so they don't get cloned on each new context. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/messages.js ('K') | « src/messages.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/uri.js
===================================================================
--- src/uri.js (revision 2657)
+++ src/uri.js (working copy)
@@ -39,6 +39,10 @@
function URIEncodeOctets(octets, result, index) {
+ if (hexCharCodeArray === 0) {
+ hexCharCodeArray = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ 65, 66, 67, 68, 69, 70];
+ }
index = URIAddEncodedOctetToBuffer(octets[0], result, index);
if (octets[1]) index = URIAddEncodedOctetToBuffer(octets[1], result, index);
if (octets[2]) index = URIAddEncodedOctetToBuffer(octets[2], result, index);
@@ -316,13 +320,11 @@
}
-const hexCharArray = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "A", "B", "C", "D", "E", "F"];
+// Lazily initialized.
+var hexCharArray = 0;
+var hexCharCodeArray = 0;
-const hexCharCodeArray = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 65, 66, 67, 68, 69, 70];
-
function HexValueOf(c) {
var code = c.charCodeAt(0);
@@ -341,6 +343,10 @@
// 64 -> 0040, 62234 -> F31A.
function CharCodeToHex4Str(cc) {
var r = "";
+ if (hexCharArray === 0) {
+ hexCharArray = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+ "A", "B", "C", "D", "E", "F"];
+ }
for (var i = 0; i < 4; ++i) {
var c = hexCharArray[cc & 0x0F];
r = c + r;
« src/messages.js ('K') | « src/messages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698