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

Side by Side Diff: src/jsregexp.cc

Issue 11880045: Cleanup latin-1 conversion check in regexp engine (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/unicode.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 for (int j = 0; j < quarks.length(); j++) { 2868 for (int j = 0; j < quarks.length(); j++) {
2869 #ifndef ENABLE_LATIN_1 2869 #ifndef ENABLE_LATIN_1
2870 if (quarks[j] > String::kMaxOneByteCharCode) { 2870 if (quarks[j] > String::kMaxOneByteCharCode) {
2871 return set_replacement(NULL); 2871 return set_replacement(NULL);
2872 } 2872 }
2873 #else 2873 #else
2874 if (quarks[j] <= String::kMaxOneByteCharCode) continue; 2874 if (quarks[j] <= String::kMaxOneByteCharCode) continue;
2875 if (!ignore_case) return set_replacement(NULL); 2875 if (!ignore_case) return set_replacement(NULL);
2876 // Here, we need to check for characters whose upper and lower cases 2876 // Here, we need to check for characters whose upper and lower cases
2877 // are outside the Latin-1 range. 2877 // are outside the Latin-1 range.
2878 // TODO(dcarney): Replace this code with a simple 2878 if (!unibrow::Latin1::NonLatin1CanBeConvertedToLatin1(quarks[j])) {
2879 // table lookup in unibrow::Latin-1. 2879 return set_replacement(NULL);
2880 // TODO(dcarney): Test cases!.
2881 unibrow::uchar result;
2882 int chars;
2883 chars = unibrow::ToLowercase::Convert(quarks[j], 0, &result, NULL);
2884 if (chars > 1 ||
2885 (chars == 1 && result <= String::kMaxOneByteCharCodeU)) {
2886 continue;
2887 } 2880 }
2888 chars = unibrow::ToUppercase::Convert(quarks[j], 0, &result, NULL);
2889 if (chars > 1 ||
2890 (chars == 1 && result <= String::kMaxOneByteCharCodeU)) {
2891 continue;
2892 }
2893 // This character is definitely not in the Latin-1 range.
2894 return set_replacement(NULL);
2895 #endif 2881 #endif
2896 } 2882 }
2897 } else { 2883 } else {
2898 ASSERT(elm.type == TextElement::CHAR_CLASS); 2884 ASSERT(elm.type == TextElement::CHAR_CLASS);
2899 #ifdef ENABLE_LATIN_1 2885 #ifdef ENABLE_LATIN_1
2900 // TODO(dcarney): Can this be improved? 2886 // TODO(dcarney): Can this be improved?
2901 if (ignore_case) continue; 2887 if (ignore_case) continue;
2902 #endif 2888 #endif
2903 RegExpCharacterClass* cc = elm.data.u_char_class; 2889 RegExpCharacterClass* cc = elm.data.u_char_class;
2904 ZoneList<CharacterRange>* ranges = cc->ranges(zone()); 2890 ZoneList<CharacterRange>* ranges = cc->ranges(zone());
(...skipping 3288 matching lines...) Expand 10 before | Expand all | Expand 10 after
6193 } 6179 }
6194 6180
6195 return compiler.Assemble(&macro_assembler, 6181 return compiler.Assemble(&macro_assembler,
6196 node, 6182 node,
6197 data->capture_count, 6183 data->capture_count,
6198 pattern); 6184 pattern);
6199 } 6185 }
6200 6186
6201 6187
6202 }} // namespace v8::internal 6188 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698