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

Side by Side Diff: src/string.js

Issue 3778004: Restructure RegExp exec cache code. (Closed)
Patch Set: Addressed review comments. Created 10 years, 2 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/regexp.js ('k') | test/mjsunit/regexp.js » ('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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 604
605 return result; 605 return result;
606 } 606 }
607 607
608 var cache = regExpCache; 608 var cache = regExpCache;
609 var saveAnswer = false; 609 var saveAnswer = false;
610 610
611 if (%_ObjectEquals(cache.type, 'split') && 611 if (%_ObjectEquals(cache.type, 'split') &&
612 %_IsRegExpEquivalent(cache.regExp, separator) && 612 %_IsRegExpEquivalent(cache.regExp, separator) &&
613 %_ObjectEquals(cache.subject, subject) && 613 %_ObjectEquals(cache.subject, subject) &&
614 %_ObjectEquals(cache.lastIndex, limit)) { 614 %_ObjectEquals(cache.splitLimit, limit)) {
615 if (cache.answerSaved) { 615 if (cache.answerSaved) {
616 return CloneDenseArray(cache.answer); 616 return CloneDenseArray(cache.answer);
617 } else { 617 } else {
618 saveAnswer = true; 618 saveAnswer = true;
619 } 619 }
620 } 620 }
621 621
622 cache.type = 'split'; 622 cache.type = 'split';
623 cache.regExp = separator; 623 cache.regExp = separator;
624 cache.subject = subject; 624 cache.subject = subject;
625 // Reuse lastIndex field for split limit when type is "split". 625 cache.splitLimit = limit;
626 cache.lastIndex = limit;
627 626
628 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]); 627 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
629 628
630 if (length === 0) { 629 if (length === 0) {
631 cache.answerSaved = true; 630 cache.answerSaved = true;
632 if (splitMatch(separator, subject, 0, 0) != null) { 631 if (splitMatch(separator, subject, 0, 0) != null) {
633 cache.answer = []; 632 cache.answer = [];
634 return []; 633 return [];
635 } 634 }
636 cache.answer = [subject]; 635 cache.answer = [subject];
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 "small", StringSmall, 999 "small", StringSmall,
1001 "strike", StringStrike, 1000 "strike", StringStrike,
1002 "sub", StringSub, 1001 "sub", StringSub,
1003 "sup", StringSup, 1002 "sup", StringSup,
1004 "toJSON", StringToJSON 1003 "toJSON", StringToJSON
1005 )); 1004 ));
1006 } 1005 }
1007 1006
1008 1007
1009 SetupString(); 1008 SetupString();
OLDNEW
« no previous file with comments | « src/regexp.js ('k') | test/mjsunit/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698