Skip to content

Commit 2d85834

Browse files
kevmoolitongjava
authored andcommitted
Dart3: update to latest SDK, general cleanup (TechEmpower#9918)
Also added in missing new-line chars at the end of a couple of files
1 parent e5ee836 commit 2d85834

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

frameworks/Dart/dart3/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Created by `dart pub`
33
.dart_tool/
44
*.lock
5-
!bin
5+
!bin

frameworks/Dart/dart3/bin/server.dart

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ import 'dart:convert';
22
import 'dart:io';
33
import 'dart:isolate';
44

5-
final _encoder = JsonUtf8Encoder();
6-
7-
void main(List<String> _) async {
8-
/// Create an [Isolate] containinig an [HttpServer]
5+
void main(List<String> args) async {
6+
/// Create an [Isolate] containing an [HttpServer]
97
/// for each processor after the first
108
for (var i = 1; i < Platform.numberOfProcessors; i++) {
11-
await Isolate.spawn(_startServer, _);
9+
await Isolate.spawn(_startServer, args);
1210
}
1311

1412
/// Create a [HttpServer] for the first processor
15-
await _startServer(_);
13+
await _startServer(args);
1614
}
1715

1816
/// Creates and setup a [HttpServer]
1917
Future<void> _startServer(List<String> _) async {
2018
/// Binds the [HttpServer] on `0.0.0.0:8080`.
2119
final server = await HttpServer.bind(
22-
InternetAddress('0.0.0.0', type: InternetAddressType.IPv4),
20+
InternetAddress.anyIPv4,
2321
8080,
2422
shared: true,
2523
);
@@ -51,39 +49,35 @@ void _sendResponse(
5149
int statusCode, {
5250
ContentType? type,
5351
List<int> bytes = const [],
54-
}) =>
55-
request.response
56-
..statusCode = statusCode
57-
..headers.contentType = type
58-
..headers.date = DateTime.now()
59-
..contentLength = bytes.length
60-
..add(bytes)
61-
..close();
52+
}) => request.response
53+
..statusCode = statusCode
54+
..headers.contentType = type
55+
..headers.date = DateTime.now()
56+
..contentLength = bytes.length
57+
..add(bytes)
58+
..close();
6259

6360
/// Completes the given [request] by writing the [response] as JSON.
6461
void _sendJson(HttpRequest request, Object response) => _sendResponse(
65-
request,
66-
HttpStatus.ok,
67-
type: ContentType.json,
68-
bytes: _encoder.convert(response),
69-
);
62+
request,
63+
HttpStatus.ok,
64+
type: ContentType.json,
65+
bytes: _jsonEncoder.convert(response),
66+
);
7067

7168
/// Completes the given [request] by writing the [response] as plain text.
7269
void _sendText(HttpRequest request, String response) => _sendResponse(
73-
request,
74-
HttpStatus.ok,
75-
type: ContentType.text,
76-
bytes: utf8.encode(response),
77-
);
70+
request,
71+
HttpStatus.ok,
72+
type: ContentType.text,
73+
bytes: utf8.encode(response),
74+
);
7875

7976
/// Responds with the JSON test to the [request].
80-
void _jsonTest(HttpRequest request) => _sendJson(
81-
request,
82-
const {'message': 'Hello, World!'},
83-
);
77+
void _jsonTest(HttpRequest request) =>
78+
_sendJson(request, const {'message': 'Hello, World!'});
8479

8580
/// Responds with the plaintext test to the [request].
86-
void _plaintextTest(HttpRequest request) => _sendText(
87-
request,
88-
'Hello, World!',
89-
);
81+
void _plaintextTest(HttpRequest request) => _sendText(request, 'Hello, World!');
82+
83+
final _jsonEncoder = JsonUtf8Encoder();

frameworks/Dart/dart3/dart3.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
FROM dart:3.5 AS builder
2+
FROM dart:3.8 AS builder
33

44
COPY . /app
55
WORKDIR /app
@@ -11,4 +11,4 @@ COPY --from=builder /runtime/ /
1111
COPY --from=builder /app/build /bin
1212

1313
EXPOSE 8080
14-
CMD ["server"]
14+
CMD ["server"]

frameworks/Dart/dart3/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: dartbenchmark
22
description: A benchmark of dart
33
environment:
4-
sdk: '>=3.5.0 <4.0.0'
4+
sdk: ^3.8.0
55

66
dev_dependencies:
77
lints: ^4.0.0

0 commit comments

Comments
 (0)