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

Side by Side Diff: src/string.js

Issue 1563005: Introduce fast native caches and use it in String.search. (Closed)
Patch Set: Last round :) Created 10 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/runtime.cc ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 522 }
523 var parameters = $Array(m + 2); 523 var parameters = $Array(m + 2);
524 for (var j = 0; j < m; j++) { 524 for (var j = 0; j < m; j++) {
525 parameters[j] = CaptureString(subject, matchInfo, j); 525 parameters[j] = CaptureString(subject, matchInfo, j);
526 } 526 }
527 parameters[j] = index; 527 parameters[j] = index;
528 parameters[j + 1] = subject; 528 parameters[j + 1] = subject;
529 return replace.apply(null, parameters); 529 return replace.apply(null, parameters);
530 } 530 }
531 531
532
533 // ECMA-262 section 15.5.4.12 532 // ECMA-262 section 15.5.4.12
534 function StringSearch(re) { 533 function StringSearch(re) {
535 var regexp = new $RegExp(re); 534 var regexp;
535 if (IS_STRING(re)) {
536 regexp = %_GetFromCache(STRING_TO_REGEXP_CACHE_ID, re);
537 } else if (IS_REGEXP(re)) {
538 regexp = re;
539 } else {
540 regexp = new $RegExp(re);
541 }
536 var s = TO_STRING_INLINE(this); 542 var s = TO_STRING_INLINE(this);
537 var match = DoRegExpExec(regexp, s, 0); 543 var match = DoRegExpExec(regexp, s, 0);
538 if (match) { 544 if (match) {
539 lastMatchInfo = match; 545 lastMatchInfo = match;
540 return match[CAPTURE0]; 546 return match[CAPTURE0];
541 } 547 }
542 return -1; 548 return -1;
543 } 549 }
544 550
545 551
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 "small", StringSmall, 1004 "small", StringSmall,
999 "strike", StringStrike, 1005 "strike", StringStrike,
1000 "sub", StringSub, 1006 "sub", StringSub,
1001 "sup", StringSup, 1007 "sup", StringSup,
1002 "toJSON", StringToJSON 1008 "toJSON", StringToJSON
1003 )); 1009 ));
1004 } 1010 }
1005 1011
1006 1012
1007 SetupString(); 1013 SetupString();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698