| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 function URIAddEncodedOctetToBuffer(octet, result, index) { | 33 function URIAddEncodedOctetToBuffer(octet, result, index) { |
| 34 result[index++] = 37; // Char code of '%'. | 34 result[index++] = 37; // Char code of '%'. |
| 35 result[index++] = hexCharCodeArray[octet >> 4]; | 35 result[index++] = hexCharCodeArray[octet >> 4]; |
| 36 result[index++] = hexCharCodeArray[octet & 0x0F]; | 36 result[index++] = hexCharCodeArray[octet & 0x0F]; |
| 37 return index; | 37 return index; |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 function URIEncodeOctets(octets, result, index) { | 41 function URIEncodeOctets(octets, result, index) { |
| 42 if (hexCharCodeArray === 0) { |
| 43 hexCharCodeArray = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 44 65, 66, 67, 68, 69, 70]; |
| 45 } |
| 42 index = URIAddEncodedOctetToBuffer(octets[0], result, index); | 46 index = URIAddEncodedOctetToBuffer(octets[0], result, index); |
| 43 if (octets[1]) index = URIAddEncodedOctetToBuffer(octets[1], result, index); | 47 if (octets[1]) index = URIAddEncodedOctetToBuffer(octets[1], result, index); |
| 44 if (octets[2]) index = URIAddEncodedOctetToBuffer(octets[2], result, index); | 48 if (octets[2]) index = URIAddEncodedOctetToBuffer(octets[2], result, index); |
| 45 if (octets[3]) index = URIAddEncodedOctetToBuffer(octets[3], result, index); | 49 if (octets[3]) index = URIAddEncodedOctetToBuffer(octets[3], result, index); |
| 46 return index; | 50 return index; |
| 47 } | 51 } |
| 48 | 52 |
| 49 | 53 |
| 50 function URIEncodeSingle(cc, result, index) { | 54 function URIEncodeSingle(cc, result, index) { |
| 51 var x = (cc >> 12) & 0xF; | 55 var x = (cc >> 12) & 0xF; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 if (cc == 126) return true; | 313 if (cc == 126) return true; |
| 310 | 314 |
| 311 return false; | 315 return false; |
| 312 }; | 316 }; |
| 313 | 317 |
| 314 var string = ToString(component); | 318 var string = ToString(component); |
| 315 return Encode(string, unescapePredicate); | 319 return Encode(string, unescapePredicate); |
| 316 } | 320 } |
| 317 | 321 |
| 318 | 322 |
| 319 const hexCharArray = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", | 323 // Lazily initialized. |
| 320 "A", "B", "C", "D", "E", "F"]; | 324 var hexCharArray = 0; |
| 321 | 325 var hexCharCodeArray = 0; |
| 322 const hexCharCodeArray = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, | |
| 323 65, 66, 67, 68, 69, 70]; | |
| 324 | 326 |
| 325 | 327 |
| 326 function HexValueOf(c) { | 328 function HexValueOf(c) { |
| 327 var code = c.charCodeAt(0); | 329 var code = c.charCodeAt(0); |
| 328 | 330 |
| 329 // 0-9 | 331 // 0-9 |
| 330 if (code >= 48 && code <= 57) return code - 48; | 332 if (code >= 48 && code <= 57) return code - 48; |
| 331 // A-F | 333 // A-F |
| 332 if (code >= 65 && code <= 70) return code - 55; | 334 if (code >= 65 && code <= 70) return code - 55; |
| 333 // a-f | 335 // a-f |
| 334 if (code >= 97 && code <= 102) return code - 87; | 336 if (code >= 97 && code <= 102) return code - 87; |
| 335 | 337 |
| 336 return -1; | 338 return -1; |
| 337 } | 339 } |
| 338 | 340 |
| 339 | 341 |
| 340 // Convert a character code to 4-digit hex string representation | 342 // Convert a character code to 4-digit hex string representation |
| 341 // 64 -> 0040, 62234 -> F31A. | 343 // 64 -> 0040, 62234 -> F31A. |
| 342 function CharCodeToHex4Str(cc) { | 344 function CharCodeToHex4Str(cc) { |
| 343 var r = ""; | 345 var r = ""; |
| 346 if (hexCharArray === 0) { |
| 347 hexCharArray = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", |
| 348 "A", "B", "C", "D", "E", "F"]; |
| 349 } |
| 344 for (var i = 0; i < 4; ++i) { | 350 for (var i = 0; i < 4; ++i) { |
| 345 var c = hexCharArray[cc & 0x0F]; | 351 var c = hexCharArray[cc & 0x0F]; |
| 346 r = c + r; | 352 r = c + r; |
| 347 cc = cc >>> 4; | 353 cc = cc >>> 4; |
| 348 } | 354 } |
| 349 return r; | 355 return r; |
| 350 } | 356 } |
| 351 | 357 |
| 352 | 358 |
| 353 // Converts hex string to char code. Not efficient. | 359 // Converts hex string to char code. Not efficient. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 "unescape", URIUnescape, | 406 "unescape", URIUnescape, |
| 401 "decodeURI", URIDecode, | 407 "decodeURI", URIDecode, |
| 402 "decodeURIComponent", URIDecodeComponent, | 408 "decodeURIComponent", URIDecodeComponent, |
| 403 "encodeURI", URIEncode, | 409 "encodeURI", URIEncode, |
| 404 "encodeURIComponent", URIEncodeComponent | 410 "encodeURIComponent", URIEncodeComponent |
| 405 )); | 411 )); |
| 406 } | 412 } |
| 407 | 413 |
| 408 SetupURI(); | 414 SetupURI(); |
| 409 | 415 |
| OLD | NEW |