aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDany Shaanan <danyshaanan@gmail.com>2016-09-17 10:34:13 +0200
committerAnna Henningsen <anna@addaleax.net>2016-09-20 14:11:31 +0200
commit5f2994723048f6d433cece23af0e11bdd97e0896 (patch)
tree4d03298d3a6f207e9c50528a1592ee8719731ce9
parent9391cb0fdeb5a247e60621abde79f0c323feb2a8 (diff)
downloadandroid-node-v8-5f2994723048f6d433cece23af0e11bdd97e0896.tar.gz
android-node-v8-5f2994723048f6d433cece23af0e11bdd97e0896.tar.bz2
android-node-v8-5f2994723048f6d433cece23af0e11bdd97e0896.zip
util: simplify SIMD setup
PR-URL: https://github.com/nodejs/node/pull/8579 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
-rw-r--r--lib/util.js44
1 files changed, 16 insertions, 28 deletions
diff --git a/lib/util.js b/lib/util.js
index 245b196393..2d7ba65163 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -38,35 +38,23 @@ if (typeof global.SIMD === 'object' && global.SIMD !== null) {
const SIMD = global.SIMD; // Pacify eslint.
- if (typeof SIMD.Bool16x8 === 'function')
- simdFormatters.set(SIMD.Bool16x8, make(SIMD.Bool16x8.extractLane, 8));
-
- if (typeof SIMD.Bool32x4 === 'function')
- simdFormatters.set(SIMD.Bool32x4, make(SIMD.Bool32x4.extractLane, 4));
-
- if (typeof SIMD.Bool8x16 === 'function')
- simdFormatters.set(SIMD.Bool8x16, make(SIMD.Bool8x16.extractLane, 16));
-
- if (typeof SIMD.Float32x4 === 'function')
- simdFormatters.set(SIMD.Float32x4, make(SIMD.Float32x4.extractLane, 4));
-
- if (typeof SIMD.Int16x8 === 'function')
- simdFormatters.set(SIMD.Int16x8, make(SIMD.Int16x8.extractLane, 8));
-
- if (typeof SIMD.Int32x4 === 'function')
- simdFormatters.set(SIMD.Int32x4, make(SIMD.Int32x4.extractLane, 4));
-
- if (typeof SIMD.Int8x16 === 'function')
- simdFormatters.set(SIMD.Int8x16, make(SIMD.Int8x16.extractLane, 16));
-
- if (typeof SIMD.Uint16x8 === 'function')
- simdFormatters.set(SIMD.Uint16x8, make(SIMD.Uint16x8.extractLane, 8));
-
- if (typeof SIMD.Uint32x4 === 'function')
- simdFormatters.set(SIMD.Uint32x4, make(SIMD.Uint32x4.extractLane, 4));
+ const countPerType = {
+ Bool16x8: 8,
+ Bool32x4: 4,
+ Bool8x16: 16,
+ Float32x4: 4,
+ Int16x8: 8,
+ Int32x4: 4,
+ Int8x16: 16,
+ Uint16x8: 8,
+ Uint32x4: 4,
+ Uint8x16: 16
+ };
- if (typeof SIMD.Uint8x16 === 'function')
- simdFormatters.set(SIMD.Uint8x16, make(SIMD.Uint8x16.extractLane, 16));
+ for (const key in countPerType) {
+ const type = SIMD[key];
+ simdFormatters.set(type, make(type.extractLane, countPerType[key]));
+ }
}
function tryStringify(arg) {