OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_STRING_SEARCH_H_ | 5 #ifndef V8_STRING_SEARCH_H_ |
6 #define V8_STRING_SEARCH_H_ | 6 #define V8_STRING_SEARCH_H_ |
7 | 7 |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/vector.h" | 9 #include "src/vector.h" |
10 | 10 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 // for each search. | 556 // for each search. |
557 template <typename SubjectChar, typename PatternChar> | 557 template <typename SubjectChar, typename PatternChar> |
558 int SearchString(Isolate* isolate, | 558 int SearchString(Isolate* isolate, |
559 Vector<const SubjectChar> subject, | 559 Vector<const SubjectChar> subject, |
560 Vector<const PatternChar> pattern, | 560 Vector<const PatternChar> pattern, |
561 int start_index) { | 561 int start_index) { |
562 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); | 562 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); |
563 return search.Search(subject, start_index); | 563 return search.Search(subject, start_index); |
564 } | 564 } |
565 | 565 |
566 // A wrapper function around SearchString that wraps raw pointers to the subject | |
567 // and pattern as vectors before calling SearchString. Used from the | |
568 // StringIndexOf builtin. | |
569 template <typename SubjectChar, typename PatternChar> | |
570 int SearchStringRaw(Isolate* isolate, const SubjectChar* subject_ptr, | |
571 int subject_length, const PatternChar* pattern_ptr, | |
572 int pattern_length, int start_index) { | |
Camillo Bruni
2017/04/18 14:12:36
DisallowHeapAllocation no_gc();
jgruber
2017/04/19 06:59:05
Good idea, done.
| |
573 Vector<const SubjectChar> subject(subject_ptr, subject_length); | |
574 Vector<const PatternChar> pattern(pattern_ptr, pattern_length); | |
575 return SearchString(isolate, subject, pattern, start_index); | |
576 } | |
577 | |
566 } // namespace internal | 578 } // namespace internal |
567 } // namespace v8 | 579 } // namespace v8 |
568 | 580 |
569 #endif // V8_STRING_SEARCH_H_ | 581 #endif // V8_STRING_SEARCH_H_ |
OLD | NEW |