Skip to content

Commit

Permalink
Make sign faster.
Browse files Browse the repository at this point in the history
Closes #54653

GitOrigin-RevId: af94934
Change-Id: I412d48ff24bd80120cf1de4e580b85eeca8e9619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346687
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
  • Loading branch information
bernaferrari authored and Commit Queue committed Jan 17, 2024
1 parent daf06f3 commit 4b273b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
9 changes: 2 additions & 7 deletions sdk/lib/_internal/vm/lib/integers.dart
Expand Up @@ -188,13 +188,8 @@ abstract final class _IntegerImplementation implements int {
return this < 0 ? -this : this;
}

int get sign {
return (this > 0)
? 1
: (this < 0)
? -1
: 0;
}
@pragma('vm:prefer-inline')
int get sign => (this >> 63) | (-this >>> 63);

bool get isEven => ((this & 1) == 0);
bool get isOdd => !isEven;
Expand Down
8 changes: 1 addition & 7 deletions sdk/lib/_internal/wasm/lib/boxed_int.dart
Expand Up @@ -136,13 +136,7 @@ final class _BoxedInt extends int {
}

@pragma("wasm:prefer-inline")
int get sign {
return (this > 0)
? 1
: (this < 0)
? -1
: 0;
}
int get sign => (this >> 63) | (-this >>> 63);

@pragma("wasm:prefer-inline")
bool get isEven => (this & 1) == 0;
Expand Down

0 comments on commit 4b273b4

Please sign in to comment.