mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 18:58:27 +00:00
[test] Remove assumption that machine word size implies Smi size.
This assumption will soon become false with compressed pointers. TEST=ci Change-Id: Ia95ffdcd0c55d649190fcd4764dc3878ecdeb6a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184540 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
4e84c97af7
commit
e1f5039854
|
@ -30,8 +30,11 @@ extension Utf8Helpers on Pointer<Utf8> {
|
|||
/// characters before the first null byte.
|
||||
int get strlen {
|
||||
final Pointer<Uint8> array = this.cast<Uint8>();
|
||||
final Uint8List nativeString = array.asTypedList(_maxSize);
|
||||
return nativeString.indexWhere((char) => char == 0);
|
||||
int length = 0;
|
||||
while (array[length] != 0) {
|
||||
length++;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
/// Creates a [String] containing the characters UTF-8 encoded in [this].
|
||||
|
@ -47,7 +50,3 @@ extension Utf8Helpers on Pointer<Utf8> {
|
|||
this.cast<Uint8>().asTypedList(length).buffer, 0, length));
|
||||
}
|
||||
}
|
||||
|
||||
const int _kMaxSmi64 = (1 << 62) - 1;
|
||||
const int _kMaxSmi32 = (1 << 30) - 1;
|
||||
final int _maxSize = sizeOf<IntPtr>() == 8 ? _kMaxSmi64 : _kMaxSmi32;
|
||||
|
|
|
@ -34,8 +34,11 @@ extension Utf8Helpers on Pointer<Utf8> {
|
|||
/// characters before the first null byte.
|
||||
int get strlen {
|
||||
final Pointer<Uint8> array = this.cast<Uint8>();
|
||||
final Uint8List nativeString = array.asTypedList(_maxSize);
|
||||
return nativeString.indexWhere((char) => char == 0);
|
||||
int length = 0;
|
||||
while (array[length] != 0) {
|
||||
length++;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
/// Creates a [String] containing the characters UTF-8 encoded in [this].
|
||||
|
@ -51,7 +54,3 @@ extension Utf8Helpers on Pointer<Utf8> {
|
|||
this.cast<Uint8>().asTypedList(length).buffer, 0, length));
|
||||
}
|
||||
}
|
||||
|
||||
const int _kMaxSmi64 = (1 << 62) - 1;
|
||||
const int _kMaxSmi32 = (1 << 30) - 1;
|
||||
final int _maxSize = sizeOf<IntPtr>() == 8 ? _kMaxSmi64 : _kMaxSmi32;
|
||||
|
|
Loading…
Reference in a new issue