OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 // algorithm is unnecessary overhead. | 1376 // algorithm is unnecessary overhead. |
1377 if (pattern_length == 1) { | 1377 if (pattern_length == 1) { |
1378 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid | 1378 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid |
1379 if (sub_shape.IsAsciiRepresentation()) { | 1379 if (sub_shape.IsAsciiRepresentation()) { |
1380 uc16 pchar = pat->Get(pat_shape, 0); | 1380 uc16 pchar = pat->Get(pat_shape, 0); |
1381 if (pchar > String::kMaxAsciiCharCode) { | 1381 if (pchar > String::kMaxAsciiCharCode) { |
1382 return -1; | 1382 return -1; |
1383 } | 1383 } |
1384 Vector<const char> ascii_vector = | 1384 Vector<const char> ascii_vector = |
1385 sub->ToAsciiVector().SubVector(start_index, subject_length); | 1385 sub->ToAsciiVector().SubVector(start_index, subject_length); |
1386 void* pos = memchr(ascii_vector.start(), | 1386 const void* pos = memchr(ascii_vector.start(), |
1387 static_cast<const char>(pchar), | 1387 static_cast<const char>(pchar), |
1388 static_cast<size_t>(ascii_vector.length())); | 1388 static_cast<size_t>(ascii_vector.length())); |
1389 if (pos == NULL) { | 1389 if (pos == NULL) { |
1390 return -1; | 1390 return -1; |
1391 } | 1391 } |
1392 return reinterpret_cast<char*>(pos) - ascii_vector.start() + start_index; | 1392 return reinterpret_cast<const char*>(pos) - ascii_vector.start() |
| 1393 + start_index; |
1393 } | 1394 } |
1394 return SingleCharIndexOf(sub->ToUC16Vector(), | 1395 return SingleCharIndexOf(sub->ToUC16Vector(), |
1395 pat->Get(pat_shape, 0), | 1396 pat->Get(pat_shape, 0), |
1396 start_index); | 1397 start_index); |
1397 } | 1398 } |
1398 | 1399 |
1399 if (!pat->IsFlat(pat_shape)) { | 1400 if (!pat->IsFlat(pat_shape)) { |
1400 FlattenString(pat); | 1401 FlattenString(pat); |
1401 pat_shape = StringShape(*pat); | 1402 pat_shape = StringShape(*pat); |
1402 sub_shape = StringShape(*sub); | 1403 sub_shape = StringShape(*sub); |
(...skipping 4504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5907 } else { | 5908 } else { |
5908 // Handle last resort GC and make sure to allow future allocations | 5909 // Handle last resort GC and make sure to allow future allocations |
5909 // to grow the heap without causing GCs (if possible). | 5910 // to grow the heap without causing GCs (if possible). |
5910 Counters::gc_last_resort_from_js.Increment(); | 5911 Counters::gc_last_resort_from_js.Increment(); |
5911 Heap::CollectAllGarbage(); | 5912 Heap::CollectAllGarbage(); |
5912 } | 5913 } |
5913 } | 5914 } |
5914 | 5915 |
5915 | 5916 |
5916 } } // namespace v8::internal | 5917 } } // namespace v8::internal |
OLD | NEW |