[js_runtime] Make _checkLength more likely to be inlined

Rewrite _checkLength to avoid weaknesses in type inference.

Change-Id: I1a254d021ff966fa51da7f8258c5cba7b3b10336
Reviewed-on: https://dart-review.googlesource.com/58542
Reviewed-by: Emily Fortuna <efortuna@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart b/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart
index e93af8f..7889c36 100644
--- a/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart
+++ b/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart
@@ -379,8 +379,9 @@
 // because passing unvalidated values to the native constructors can cause
 // conversions or create views.
 int _checkLength(length) {
-  if (length is! int) throw new ArgumentError('Invalid length $length');
-  return length;
+  return length is int
+      ? length
+      : throw new ArgumentError('Invalid length $length');
 }
 
 // Validates `.view` constructor arguments.  Checking is necessary because