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

Unified Diff: lib/compiler/implementation/source_file.dart

Issue 11275097: Merge SourceLocation and Source (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: RegExp used for line numbers Created 8 years, 1 month 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 | pkg/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/source_file.dart
diff --git a/lib/compiler/implementation/source_file.dart b/lib/compiler/implementation/source_file.dart
index d517e76eb22146f4e81039495b7ef84cc88c7edb..9ba3b2bc810d53a6b5df3e635ed2244c813f94e1 100644
--- a/lib/compiler/implementation/source_file.dart
+++ b/lib/compiler/implementation/source_file.dart
@@ -26,11 +26,8 @@ class SourceFile {
List<int> get lineStarts {
if (_lineStarts == null) {
var starts = [0];
- var index = 0;
- while (index < text.length) {
- index = text.indexOf('\n', index) + 1;
- if (index <= 0) break;
- starts.add(index);
+ for (Match match in const RegExp("\r\n?|\n\r?").allMatches(text)) {
+ starts.add(match.start + 1);
ahe 2012/11/01 13:05:22 What is the performance overhead of this? Perhaps
Johnni Winther 2012/11/01 15:27:13 Enormous. I'll revert.
}
starts.add(text.length + 1);
_lineStarts = starts;
« no previous file with comments | « no previous file | pkg/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698