Skip to content

Commit

Permalink
add an optimization for "ref-struct" types, and potentially other "wr…
Browse files Browse the repository at this point in the history
…apper" types
  • Loading branch information
TooTallNate committed May 16, 2012
1 parent c350f9c commit 44ac2da
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/foreign_function.js
Expand Up @@ -62,7 +62,13 @@ function ForeignFunction (func, returnType, argTypes, abi) {
var argType = argTypes[i]
, val = arguments[i]

var valPtr = ref.alloc(argType, val)
var valPtr
if (val && val._pointer) {
debug('using the "_pointer" property for argument at index', i)
valPtr = val._pointer
} else {
valPtr = ref.alloc(argType, val)
}
argsList.writePointer(valPtr, i * POINTER_SIZE)
}

Expand Down Expand Up @@ -101,7 +107,13 @@ function ForeignFunction (func, returnType, argTypes, abi) {
var argType = argTypes[i]
, val = arguments[i]

var valPtr = ref.alloc(argType, val)
var valPtr
if (val && val._pointer) {
debug('using the "_pointer" property for argument at index', i)
valPtr = val._pointer
} else {
valPtr = ref.alloc(argType, val)
}
argsList.writePointer(valPtr, i * POINTER_SIZE)
}

Expand Down

0 comments on commit 44ac2da

Please sign in to comment.