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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/completion_performance.dart

Issue 1941793002: Use null aware operators to clean up code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 services.completion.manager; 5 library services.completion.manager;
6 6
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 8
9 /** 9 /**
10 * Overall performance of a code completion operation. 10 * Overall performance of a code completion operation.
(...skipping 24 matching lines...) Expand all
35 String get startTimeAndMs => '${start.millisecondsSinceEpoch} - $start'; 35 String get startTimeAndMs => '${start.millisecondsSinceEpoch} - $start';
36 36
37 String get suggestionCount { 37 String get suggestionCount {
38 if (notificationCount < 1) return ''; 38 if (notificationCount < 1) return '';
39 if (notificationCount == 1) return '$suggestionCountFirst'; 39 if (notificationCount == 1) return '$suggestionCountFirst';
40 return '$suggestionCountFirst, $suggestionCountLast'; 40 return '$suggestionCountFirst, $suggestionCountLast';
41 } 41 }
42 42
43 void complete([String tag = null]) { 43 void complete([String tag = null]) {
44 _stopwatch.stop(); 44 _stopwatch.stop();
45 _logDuration(tag != null ? tag : 'total time', _stopwatch.elapsed); 45 _logDuration(tag ?? 'total time', _stopwatch.elapsed);
46 } 46 }
47 47
48 void logElapseTime(String tag) { 48 void logElapseTime(String tag) {
49 Duration end = _stopwatch.elapsed; 49 Duration end = _stopwatch.elapsed;
50 Duration start = _startTimes[tag]; 50 Duration start = _startTimes[tag];
51 if (start == null) { 51 if (start == null) {
52 _logDuration(tag, null); 52 _logDuration(tag, null);
53 return null; 53 return null;
54 } 54 }
55 _logDuration(tag, end - start); 55 _logDuration(tag, end - start);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 */ 110 */
111 final String name; 111 final String name;
112 112
113 /** 113 /**
114 * The elapse time or `null` if undefined. 114 * The elapse time or `null` if undefined.
115 */ 115 */
116 final Duration elapsed; 116 final Duration elapsed;
117 117
118 OperationPerformance(this.name, this.elapsed); 118 OperationPerformance(this.name, this.elapsed);
119 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698