diff options
author | Jukka Jylanki <jjylanki@imvu.com> | 2013-03-27 09:07:03 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:26:52 +0300 |
commit | c424c0ac7f08fa4ce0e2eac1db1f5c53733bbb14 (patch) | |
tree | a19f7d924de44c3ef0616f74e0d5ebbdbc4030e0 | |
parent | 0c11a28ccfa3716962c7424fe227c82edc04de16 (diff) |
Annotate a few places where -O3 level unsafe optimizations could be performed by registering a faster form of toWireType function that omits type checks. toWireType can potentially be a 'hot' function in C++<->JS interop.
-rwxr-xr-x | src/embind/embind.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 1a2cec44..f52e80ec 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -236,6 +236,8 @@ function __embind_register_integer(primitiveType, name, minRange, maxRange) { return value; }, toWireType: function(destructors, value) { + // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could + // avoid the following two if()s and assume value is of proper type. if (typeof value !== "number") { throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name); } @@ -255,6 +257,8 @@ function __embind_register_float(rawType, name) { return value; }, toWireType: function(destructors, value) { + // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could + // avoid the following if() and assume value is of proper type. if (typeof value !== "number") { throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' +this.name); } @@ -485,6 +489,8 @@ function __embind_register_struct( }, toWireType: function(destructors, o) { var fields = this.fields; + // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: + // assume all fields are present without checking. for (var fieldName in fields) { if (!(fieldName in o)) { throw new TypeError('Missing field'); |