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

Unified Diff: src/objects.cc

Issue 821383009: Correctly parse line ends for debugging. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 5e772ab93efbebf9493ed26638c5aaa513d047c5..10ae80a37f0578790340843bc85ba14935a277f5 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8764,20 +8764,18 @@ static void CalculateLineEndsImpl(Isolate* isolate,
Vector<const SourceChar> src,
bool include_ending_line) {
const int src_len = src.length();
- StringSearch<uint8_t, SourceChar> search(isolate, STATIC_CHAR_VECTOR("\n"));
-
- // Find and record line ends.
- int position = 0;
- while (position != -1 && position < src_len) {
- position = search.Search(src, position);
- if (position != -1) {
- line_ends->Add(position);
- position++;
- } else if (include_ending_line) {
- // Even if the last line misses a line end, it is counted.
- line_ends->Add(src_len);
- return;
- }
+ UnicodeCache* cache = isolate->unicode_cache();
+ for (int i = 0; i < src_len - 1; i++) {
+ SourceChar current = src[i];
+ SourceChar next = src[i + 1];
+ if (cache->IsLineTerminatorSequence(current, next)) line_ends->Add(i);
+ }
+
+ if (src_len > 0 && cache->IsLineTerminatorSequence(src[src_len - 1], 0)) {
+ line_ends->Add(src_len - 1);
+ } else if (include_ending_line) {
+ // Even if the last line misses a line end, it is counted.
+ line_ends->Add(src_len);
}
}
« no previous file with comments | « no previous file | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698