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

Side by Side Diff: tools/testing/dart/status_file_parser.dart

Issue 258523006: Reduce memory usage of test.dart: canonicalize Set<Expectation> (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 status_file_parser; 5 library status_file_parser;
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:convert" show LineSplitter, UTF8; 8 import "dart:convert" show LineSplitter, UTF8;
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 this.issue, 246 this.issue,
247 this.lineNumber); 247 this.lineNumber);
248 248
249 bool get hasIssue => issue != null; 249 bool get hasIssue => issue != null;
250 250
251 String toString() => 'TestRule($name, $expression, $issue)'; 251 String toString() => 'TestRule($name, $expression, $issue)';
252 } 252 }
253 253
254 254
255 class TestExpectations { 255 class TestExpectations {
256 // Only create one copy of each Set<Expectation>.
257 // We just use .toString as a key, so we may make a few
258 // sets that only differ in their toString element order.
259 static Map _cachedSets = new Map();
260
256 Map _map; 261 Map _map;
257 bool _preprocessed = false; 262 bool _preprocessed = false;
258 Map _regExpCache; 263 Map _regExpCache;
259 Map _keyToRegExps; 264 Map _keyToRegExps;
260 265
261 /** 266 /**
262 * Create a TestExpectations object. See the [expectations] method 267 * Create a TestExpectations object. See the [expectations] method
263 * for an explanation of matching. 268 * for an explanation of matching.
264 */ 269 */
265 TestExpectations() : _map = new Map(); 270 TestExpectations() : _map = new Map();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // If all components of the status file key matches the filename 310 // If all components of the status file key matches the filename
306 // add the expectations to the result. 311 // add the expectations to the result.
307 result.addAll(expectation); 312 result.addAll(expectation);
308 }); 313 });
309 314
310 // If no expectations were found the expectation is that the test 315 // If no expectations were found the expectation is that the test
311 // passes. 316 // passes.
312 if (result.isEmpty) { 317 if (result.isEmpty) {
313 result.add(Expectation.PASS); 318 result.add(Expectation.PASS);
314 } 319 }
315 return result; 320 return _cachedSets.putIfAbsent(result.toString(), () => result);
316 } 321 }
317 322
318 // Preprocess the expectations for matching against 323 // Preprocess the expectations for matching against
319 // filenames. Generate lists of regular expressions once and for all 324 // filenames. Generate lists of regular expressions once and for all
320 // for each key. 325 // for each key.
321 void _preprocessForMatching() { 326 void _preprocessForMatching() {
322 if (_preprocessed) return; 327 if (_preprocessed) return;
323 328
324 _keyToRegExps = new Map(); 329 _keyToRegExps = new Map();
325 _regExpCache = new Map(); 330 _regExpCache = new Map();
(...skipping 12 matching lines...) Expand all
338 } 343 }
339 regExps[i] = regExp; 344 regExps[i] = regExp;
340 } 345 }
341 _keyToRegExps[key] = regExps; 346 _keyToRegExps[key] = regExps;
342 }); 347 });
343 348
344 _regExpCache = null; 349 _regExpCache = null;
345 _preprocessed = true; 350 _preprocessed = true;
346 } 351 }
347 } 352 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698