| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.io.source_file; | 5 library dart2js.io.source_file; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 import 'dart:convert' show UTF8; | 8 import 'dart:convert' show UTF8; |
| 9 | 9 |
| 10 import 'line_column_provider.dart'; | 10 import 'line_column_provider.dart'; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 class Utf8BytesSourceFile extends SourceFile { | 171 class Utf8BytesSourceFile extends SourceFile { |
| 172 final Uri uri; | 172 final Uri uri; |
| 173 | 173 |
| 174 /** The UTF-8 encoded content of the source file. */ | 174 /** The UTF-8 encoded content of the source file. */ |
| 175 final List<int> content; | 175 final List<int> content; |
| 176 | 176 |
| 177 Utf8BytesSourceFile(this.uri, this.content); | 177 Utf8BytesSourceFile(this.uri, this.content); |
| 178 | 178 |
| 179 String slowText() => UTF8.decode(content); | 179 String slowText() { |
| 180 // Don't include the last '0' used by the scanner. |
| 181 return UTF8.decode(content.sublist(0, content.length - 1)); |
| 182 } |
| 180 | 183 |
| 181 List<int> slowUtf8Bytes() => content; | 184 List<int> slowUtf8Bytes() => content; |
| 182 | 185 |
| 183 String slowSubstring(int start, int end) { | 186 String slowSubstring(int start, int end) { |
| 184 // TODO(lry): to make this faster, the scanner could record the UTF-8 slack | 187 // TODO(lry): to make this faster, the scanner could record the UTF-8 slack |
| 185 // for all positions of the source text. We could use [:content.sublist:]. | 188 // for all positions of the source text. We could use [:content.sublist:]. |
| 186 return slowText().substring(start, end); | 189 return slowText().substring(start, end); |
| 187 } | 190 } |
| 188 | 191 |
| 189 int get length { | 192 int get length { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 230 |
| 228 int get length => text.length; | 231 int get length => text.length; |
| 229 set length(int v) { } | 232 set length(int v) { } |
| 230 | 233 |
| 231 String slowText() => text; | 234 String slowText() => text; |
| 232 | 235 |
| 233 List<int> slowUtf8Bytes() => UTF8.encode(text); | 236 List<int> slowUtf8Bytes() => UTF8.encode(text); |
| 234 | 237 |
| 235 String slowSubstring(int start, int end) => text.substring(start, end); | 238 String slowSubstring(int start, int end) => text.substring(start, end); |
| 236 } | 239 } |
| OLD | NEW |