Skip to content

Commit dc7e9da

Browse files
kevmooCommit Queue
authored andcommitted
lib: drop unnecessary new and const
CoreLibraryReviewExempt: no API changes TEST=no behavior changes Change-Id: Ibef80bbfb000026042e562014b672258a5f1860d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419761 Reviewed-by: Lasse Nielsen <[email protected]> Reviewed-by: Liam Appelbe <[email protected]> Commit-Queue: Kevin Moore <[email protected]>
1 parent b18df09 commit dc7e9da

File tree

88 files changed

+1347
-1441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1347
-1441
lines changed

sdk/lib/_internal/vm/bin/builtin.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void _requestPackagesMap(Uri? packageConfig) {
189189
assert(msg.length >= 2);
190190
assert(msg[1] == null);
191191
_packageConfig = Uri.parse(msg[0]);
192-
final pmap = new Map<String, Uri>();
192+
final pmap = Map<String, Uri>();
193193
_packageMap = pmap;
194194
for (var i = 2; i < msg.length; i += 2) {
195195
// TODO(iposva): Complain about duplicate entries.
@@ -335,7 +335,7 @@ _findPackagesConfiguration(bool traceLoading, Uri base) {
335335
// of
336336
// - .packages (preferred)
337337
// - .dart_tool/package_config.json
338-
var currentDir = new File.fromUri(base).parent;
338+
var currentDir = File.fromUri(base).parent;
339339
while (true) {
340340
final dirUri = currentDir.uri;
341341

@@ -497,7 +497,7 @@ void _Init(
497497
_setupHooks();
498498

499499
// _workingDirectory must be set first.
500-
_workingDirectory = new Uri.directory(workingDirectory);
500+
_workingDirectory = Uri.directory(workingDirectory);
501501

502502
// setup _rootScript.
503503
if (rootScript != null) {
@@ -521,7 +521,7 @@ void _setWorkingDirectory(String cwd) {
521521
if (_traceLoading) {
522522
_log('Setting working directory: $cwd');
523523
}
524-
_workingDirectory = new Uri.directory(cwd);
524+
_workingDirectory = Uri.directory(cwd);
525525
if (_traceLoading) {
526526
_log('Working directory URI: $_workingDirectory');
527527
}

sdk/lib/_internal/vm/bin/directory_patch.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class _Directory {
5353
class _AsyncDirectoryListerOps {
5454
@patch
5555
factory _AsyncDirectoryListerOps(int pointer) =>
56-
new _AsyncDirectoryListerOpsImpl(pointer);
56+
_AsyncDirectoryListerOpsImpl(pointer);
5757
}
5858

5959
base class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1
6060
implements _AsyncDirectoryListerOps {
6161
_AsyncDirectoryListerOpsImpl._();
6262

6363
factory _AsyncDirectoryListerOpsImpl(int pointer) =>
64-
new _AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
64+
_AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
6565

6666
@pragma("vm:external-name", "Directory_SetAsyncDirectoryListerPointer")
6767
external void _setPointer(int pointer);
@@ -79,13 +79,13 @@ Uri _uriBaseClosure() {
7979
}
8080
var result = _Directory._current(_Namespace._namespace);
8181
if (result is OSError) {
82-
throw new FileSystemException._fromOSError(
82+
throw FileSystemException._fromOSError(
8383
result,
8484
"Getting current working directory failed",
8585
"",
8686
);
8787
}
88-
return new Uri.directory(result as String);
88+
return Uri.directory(result as String);
8989
}
9090

9191
@pragma("vm:entry-point", "call")

sdk/lib/_internal/vm/bin/file_patch.dart

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class _File {
9191
class _RandomAccessFileOps {
9292
@patch
9393
factory _RandomAccessFileOps(int pointer) =>
94-
new _RandomAccessFileOpsImpl(pointer);
94+
_RandomAccessFileOpsImpl(pointer);
9595
}
9696

9797
@pragma("vm:entry-point")
@@ -100,7 +100,7 @@ base class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1
100100
_RandomAccessFileOpsImpl._();
101101

102102
factory _RandomAccessFileOpsImpl(int pointer) =>
103-
new _RandomAccessFileOpsImpl._().._setPointer(pointer);
103+
_RandomAccessFileOpsImpl._().._setPointer(pointer);
104104

105105
@pragma("vm:external-name", "File_SetPointer")
106106
external void _setPointer(int pointer);
@@ -156,7 +156,7 @@ abstract class _FileSystemWatcher {
156156
_WatcherPath? _watcherPath;
157157

158158
final StreamController<FileSystemEvent> _broadcastController =
159-
new StreamController<FileSystemEvent>.broadcast();
159+
StreamController<FileSystemEvent>.broadcast();
160160

161161
/// Subscription on the stream returned by [_watchPath].
162162
///
@@ -171,26 +171,22 @@ abstract class _FileSystemWatcher {
171171
bool recursive,
172172
) {
173173
if (Platform.isLinux || Platform.isAndroid) {
174-
return new _InotifyFileSystemWatcher(path, events, recursive)._stream;
174+
return _InotifyFileSystemWatcher(path, events, recursive)._stream;
175175
}
176176
if (Platform.isWindows) {
177-
return new _Win32FileSystemWatcher(path, events, recursive)._stream;
177+
return _Win32FileSystemWatcher(path, events, recursive)._stream;
178178
}
179179
if (Platform.isMacOS) {
180-
return new _FSEventStreamFileSystemWatcher(
181-
path,
182-
events,
183-
recursive,
184-
)._stream;
180+
return _FSEventStreamFileSystemWatcher(path, events, recursive)._stream;
185181
}
186-
throw new FileSystemException(
182+
throw FileSystemException(
187183
"File system watching is not supported on this platform",
188184
);
189185
}
190186

191187
_FileSystemWatcher._(this._path, this._events, this._recursive) {
192188
if (!isSupported) {
193-
throw new FileSystemException(
189+
throw FileSystemException(
194190
"File system watching is not supported on this platform",
195191
_path,
196192
);
@@ -236,7 +232,7 @@ abstract class _FileSystemWatcher {
236232
return;
237233
}
238234
if (!_idMap.containsKey(pathId)) {
239-
_idMap[pathId] = new _WatcherPath(pathId, _path, _events);
235+
_idMap[pathId] = _WatcherPath(pathId, _path, _events);
240236
}
241237
_watcherPath = _idMap[pathId];
242238
_watcherPath!.count++;
@@ -324,9 +320,9 @@ abstract class _FileSystemWatcher {
324320

325321
void rewriteMove(event, isDir) {
326322
if (event[3]) {
327-
add(event[4], new FileSystemCreateEvent(getPath(event), isDir));
323+
add(event[4], FileSystemCreateEvent(getPath(event), isDir));
328324
} else {
329-
add(event[4], new FileSystemDeleteEvent(getPath(event), false));
325+
add(event[4], FileSystemDeleteEvent(getPath(event), false));
330326
}
331327
}
332328

@@ -344,13 +340,13 @@ abstract class _FileSystemWatcher {
344340
bool isDir = getIsDir(event);
345341
var path = getPath(event);
346342
if ((event[0] & FileSystemEvent.create) != 0) {
347-
add(event[4], new FileSystemCreateEvent(path, isDir));
343+
add(event[4], FileSystemCreateEvent(path, isDir));
348344
}
349345
if ((event[0] & FileSystemEvent.modify) != 0) {
350-
add(event[4], new FileSystemModifyEvent(path, isDir, true));
346+
add(event[4], FileSystemModifyEvent(path, isDir, true));
351347
}
352348
if ((event[0] & FileSystemEvent._modifyAttributes) != 0) {
353-
add(event[4], new FileSystemModifyEvent(path, isDir, false));
349+
add(event[4], FileSystemModifyEvent(path, isDir, false));
354350
}
355351
if ((event[0] & FileSystemEvent.move) != 0) {
356352
int link = event[1];
@@ -359,7 +355,7 @@ abstract class _FileSystemWatcher {
359355
if (pair[pathId].containsKey(link)) {
360356
add(
361357
event[4],
362-
new FileSystemMoveEvent(
358+
FileSystemMoveEvent(
363359
getPath(pair[pathId][link]),
364360
isDir,
365361
path,
@@ -374,10 +370,10 @@ abstract class _FileSystemWatcher {
374370
}
375371
}
376372
if ((event[0] & FileSystemEvent.delete) != 0) {
377-
add(event[4], new FileSystemDeleteEvent(path, false));
373+
add(event[4], FileSystemDeleteEvent(path, false));
378374
}
379375
if ((event[0] & FileSystemEvent._deleteSelf) != 0) {
380-
add(event[4], new FileSystemDeleteEvent(path, false));
376+
add(event[4], FileSystemDeleteEvent(path, false));
381377
// Signal done event.
382378
stops.add([event[4], null]);
383379
}
@@ -479,7 +475,7 @@ class _InotifyFileSystemWatcher extends _FileSystemWatcher {
479475
Stream<FileSystemEvent> _pathWatched() {
480476
var pathId = _watcherPath!.pathId;
481477
if (!_idMap.containsKey(pathId)) {
482-
_idMap[pathId] = new StreamController<FileSystemEvent>.broadcast();
478+
_idMap[pathId] = StreamController<FileSystemEvent>.broadcast();
483479
}
484480
return _idMap[pathId]!.stream;
485481
}
@@ -501,7 +497,7 @@ class _Win32FileSystemWatcher extends _FileSystemWatcher {
501497

502498
Stream<FileSystemEvent> _pathWatched() {
503499
var pathId = _watcherPath!.pathId;
504-
_controller = new StreamController<FileSystemEvent>();
500+
_controller = StreamController<FileSystemEvent>();
505501
_subscription = _FileSystemWatcher._listenOnSocket(
506502
pathId,
507503
0,
@@ -533,7 +529,7 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
533529
Stream<FileSystemEvent> _pathWatched() {
534530
var pathId = _watcherPath!.pathId;
535531
var socketId = _FileSystemWatcher._getSocketId(0, pathId);
536-
_controller = new StreamController<FileSystemEvent>();
532+
_controller = StreamController<FileSystemEvent>();
537533
_subscription = _FileSystemWatcher._listenOnSocket(
538534
socketId,
539535
0,
@@ -556,5 +552,5 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
556552

557553
@pragma("vm:entry-point", "call")
558554
Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) {
559-
return new Uint8List.view(source.buffer, offsetInBytes, length);
555+
return Uint8List.view(source.buffer, offsetInBytes, length);
560556
}

sdk/lib/_internal/vm/bin/filter_patch.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class RawZLibFilter {
6666
int strategy,
6767
List<int>? dictionary,
6868
bool raw,
69-
) => new _ZLibDeflateFilter(
69+
) => _ZLibDeflateFilter(
7070
gzip,
7171
level,
7272
windowBits,
@@ -81,5 +81,5 @@ class RawZLibFilter {
8181
int windowBits,
8282
List<int>? dictionary,
8383
bool raw,
84-
) => new _ZLibInflateFilter(gzip, windowBits, dictionary, raw);
84+
) => _ZLibInflateFilter(gzip, windowBits, dictionary, raw);
8585
}

sdk/lib/_internal/vm/bin/io_service_patch.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class _IOService {
1717
assert(data.length == 2);
1818
_forwardResponse(data[0] as int, data[1]);
1919
}, 'IO Service');
20-
static HashMap<int, Completer> _messageMap = new HashMap<int, Completer>();
20+
static HashMap<int, Completer> _messageMap = HashMap<int, Completer>();
2121
static int _id = 0;
2222

2323
@patch
@@ -26,7 +26,7 @@ class _IOService {
2626
do {
2727
id = _getNextId();
2828
} while (_messageMap.containsKey(id));
29-
final Completer completer = new Completer();
29+
final Completer completer = Completer();
3030
try {
3131
if (_messageMap.isEmpty) {
3232
// This is the first outgoing request after being in an idle state,

sdk/lib/_internal/vm/bin/namespace_patch.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ base class _NamespaceImpl extends NativeFieldWrapperClass1
2020
// embedder with the platform-specific namespace information.
2121
static _NamespaceImpl? _cachedNamespace = null;
2222
static void _setupNamespace(var namespace) {
23-
_cachedNamespace = _create(new _NamespaceImpl._(), namespace);
23+
_cachedNamespace = _create(_NamespaceImpl._(), namespace);
2424
}
2525

2626
static _NamespaceImpl get _namespace {
2727
if (_cachedNamespace == null) {
2828
// The embedder has not supplied a namespace before one is needed, so
2929
// instead use a safe-ish default value.
30-
_cachedNamespace = _create(new _NamespaceImpl._(), _getDefault());
30+
_cachedNamespace = _create(_NamespaceImpl._(), _getDefault());
3131
}
3232
return _cachedNamespace!;
3333
}

sdk/lib/_internal/vm/bin/platform_patch.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class _Platform {
6060
path.startsWith('file:')) {
6161
return Uri.parse(path);
6262
} else {
63-
return Uri.base.resolveUri(new Uri.file(path));
63+
return Uri.base.resolveUri(Uri.file(path));
6464
}
6565
});
6666
}

0 commit comments

Comments
 (0)