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) { |
| 573 DisallowHeapAllocation no_gc; |
| 574 Vector<const SubjectChar> subject(subject_ptr, subject_length); |
| 575 Vector<const PatternChar> pattern(pattern_ptr, pattern_length); |
| 576 return SearchString(isolate, subject, pattern, start_index); |
| 577 } |
| 578 |
566 } // namespace internal | 579 } // namespace internal |
567 } // namespace v8 | 580 } // namespace v8 |
568 | 581 |
569 #endif // V8_STRING_SEARCH_H_ | 582 #endif // V8_STRING_SEARCH_H_ |
OLD | NEW |