| 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 #include <limits.h> | 5 #include <limits.h> |
| 6 #include <stdarg.h> | 6 #include <stdarg.h> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 | 504 |
| 505 | 505 |
| 506 bool IsNonArrayIndexInteger(String* string) { | 506 bool IsNonArrayIndexInteger(String* string) { |
| 507 const int kBufferSize = 64; | 507 const int kBufferSize = 64; |
| 508 const int kUint32MaxChars = 11; | 508 const int kUint32MaxChars = 11; |
| 509 uint16_t buffer[kBufferSize]; | 509 uint16_t buffer[kBufferSize]; |
| 510 int offset = 0; | 510 int offset = 0; |
| 511 const int length = string->length(); | 511 const int length = string->length(); |
| 512 DCHECK_NE(0, length); | 512 if (length == 0) return false; |
| 513 // First iteration, check for minus, 0 followed by anything else, etc. | 513 // First iteration, check for minus, 0 followed by anything else, etc. |
| 514 int to = std::min(offset + kUint32MaxChars, length); | 514 int to = std::min(offset + kUint32MaxChars, length); |
| 515 { | 515 { |
| 516 String::WriteToFlat(string, buffer, offset, to); | 516 String::WriteToFlat(string, buffer, offset, to); |
| 517 bool negative = false; | 517 bool negative = false; |
| 518 if (buffer[offset] == '-') { | 518 if (buffer[offset] == '-') { |
| 519 negative = true; | 519 negative = true; |
| 520 ++offset; | 520 ++offset; |
| 521 if (offset == to) return false; // Just '-' is bad. | 521 if (offset == to) return false; // Just '-' is bad. |
| 522 } | 522 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 547 } | 547 } |
| 548 if (offset == length) break; | 548 if (offset == length) break; |
| 549 // Read next chunk. | 549 // Read next chunk. |
| 550 to = std::min(offset + kBufferSize, length); | 550 to = std::min(offset + kBufferSize, length); |
| 551 String::WriteToFlat(string, buffer, offset, to); | 551 String::WriteToFlat(string, buffer, offset, to); |
| 552 i = 0; | 552 i = 0; |
| 553 } | 553 } |
| 554 return true; | 554 return true; |
| 555 } | 555 } |
| 556 } } // namespace v8::internal | 556 } } // namespace v8::internal |
| OLD | NEW |