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

Unified Diff: src/uri.js

Issue 6460038: Version 3.1.3.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 10 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
« no previous file with comments | « src/scanner.cc ('k') | src/v8globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/uri.js
===================================================================
--- src/uri.js (revision 6703)
+++ src/uri.js (working copy)
@@ -90,11 +90,13 @@
}
-function URIHexCharsToCharCode(ch1, ch2) {
- if (HexValueOf(ch1) == -1 || HexValueOf(ch2) == -1) {
+function URIHexCharsToCharCode(highChar, lowChar) {
+ var highCode = HexValueOf(highChar);
+ var lowCode = HexValueOf(lowChar);
+ if (highCode == -1 || lowCode == -1) {
throw new $URIError("URI malformed");
}
- return HexStrToCharCode(ch1 + ch2);
+ return (highCode << 4) | lowCode;
}
@@ -196,7 +198,7 @@
var ch = uri.charAt(k);
if (ch == '%') {
if (k + 2 >= uriLength) throw new $URIError("URI malformed");
- var cc = URIHexCharsToCharCode(uri.charAt(++k), uri.charAt(++k));
+ var cc = URIHexCharsToCharCode(uri.charCodeAt(++k), uri.charCodeAt(++k));
if (cc >> 7) {
var n = 0;
while (((cc << ++n) & 0x80) != 0) ;
@@ -206,7 +208,7 @@
if (k + 3 * (n - 1) >= uriLength) throw new $URIError("URI malformed");
for (var i = 1; i < n; i++) {
if (uri.charAt(++k) != '%') throw new $URIError("URI malformed");
- octets[i] = URIHexCharsToCharCode(uri.charAt(++k), uri.charAt(++k));
+ octets[i] = URIHexCharsToCharCode(uri.charCodeAt(++k), uri.charCodeAt(++k));
}
index = URIDecodeOctets(octets, result, index);
} else {
@@ -325,9 +327,7 @@
}
-function HexValueOf(c) {
- var code = c.charCodeAt(0);
-
+function HexValueOf(code) {
// 0-9
if (code >= 48 && code <= 57) return code - 48;
// A-F
@@ -356,18 +356,6 @@
}
-// Converts hex string to char code. Not efficient.
-function HexStrToCharCode(s) {
- var m = 0;
- var r = 0;
- for (var i = s.length - 1; i >= 0; --i) {
- r = r + (HexValueOf(s.charAt(i)) << m);
- m = m + 4;
- }
- return r;
-}
-
-
// Returns true if all digits in string s are valid hex numbers
function IsValidHex(s) {
for (var i = 0; i < s.length; ++i) {
« no previous file with comments | « src/scanner.cc ('k') | src/v8globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698