Skip to content

Commit 9c917b0

Browse files
CopilotMrAlders0n
andcommitted
Use math.min() for clearer intent in buffer_utils.dart
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
1 parent 11100fd commit 9c917b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/services/meshcore/buffer_utils.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'dart:math' as math;
23
import 'dart:typed_data';
34

45
/// Buffer reader for parsing binary data from MeshCore devices
@@ -206,7 +207,7 @@ class BufferWriter {
206207
final bytes = Uint8List(maxLength);
207208

208209
// Copy string bytes up to maxLength - 1
209-
final copyLength = encoded.length < maxLength - 1 ? encoded.length : maxLength - 1;
210+
final copyLength = math.min(encoded.length, maxLength - 1);
210211
for (int i = 0; i < copyLength; i++) {
211212
bytes[i] = encoded[i];
212213
}

0 commit comments

Comments
 (0)