There are a bunch of optimizations going into object literal handling, so
the two versions are not at all equivalent: the JS version is expected to
be much faster. To make them more comparable, you could model the same
control flow in JS, roughly:
var input = {
"_id": {
"$oid": "5a00ba
Thanks for the quick feedback!
I rewrote the JS version to be closer to the native one:
var array = [];
var input = {
"_id": {
"$oid": "5a00bad8f759511811e030ba"
},
"attributes": [
{
"key": "smartshape.scene.node.path|default",
"value": "/scene/Lot444.scene",
"type
>
> Now it takes *30ms. That's still 5x faster* than the native code.
300ms. (not 30)
On Wed, Nov 15, 2017 at 10:27 AM, Jean-Marc Le Roux <
jeanmarc.ler...@aerys.in> wrote:
> Thanks for the quick feedback!
>
> I rewrote the JS version to be closer to the native one:
>
> var array = [];
> var in
So I've found a solution to make things lazy: I set an accessor instead of
decoding/setting the actual value.
void
getter(Local property, const PropertyCallbackInfo& info)
{
Isolate* isolate = info.GetIsolate();
const bson_t* document = reinterpret_cast(
info.This()
I assume you're storing references to the objects as Persistent? All you
need to do then is call SetWeak()
https://v8docs.nodesource.com/node-0.10/d2/d78/classv8_1_1_persistent.html
void MakeWeak (void *parameters, WeakReferenceCallback callback)
the callback is called when the object is GC'd.
>
> I assume you're storing references to the objects as Persistent?
Nope. You've got the whole code up there.
So if I understand correctly:
- the objects I need to keep track of the lifecycle should be made
Persistent ;
- all the other values can be set as Local ;
- I should set the
On Thu, Nov 16, 2017 at 1:24 AM, Jean-Marc Le Roux wrote:
> I assume you're storing references to the objects as Persistent?
>
>
> Nope. You've got the whole code up there.
> So if I understand correctly:
>
>- the objects I need to keep track of the lifecycle should be made
>Persistent ;
>
> Node offers a C++ Clss extention ObjectWrap
Thanks !
It is related to node. Yet I'm not sure how I'm supposed to use ObjectWrap.
I understand I have to create my own class that extends ObjectWrap and
implement a proper destructor.
Then I'll instanciate that class to wrap my Local. But how do
You don't manage the instance, the v8 engine does. When it's no longer
referenced in the engine, it's garbage collected which triggers the
callback set when the perisstent object is made weak.
You don't need to keep it anywhere, the object returned into the engine has
Internal Fields ( SetInterna
Thanks for the great help!
I think it makes a lot of sense now.
So I've extended ObjectWrap like so:
class BSONObject : public node::ObjectWrap
> {
> private:
> bson_t* _bson;
> public:
> BSONObject(bson_t* bson, Local tpl) :
> _bson(bson)
> {
> Local obj = tpl->NewIns
My assumption is that my test app terminates before the GC has a chance to
run.
To test this:
- I run node with the --expose-gc option
- I call global.gc() at the end of my test app
In this case, the destructor of my ObjectWrap is indeed called.
*So it seams the GC doesn't simply "collect
On Fri, Nov 17, 2017 at 7:25 AM, Jean-Marc Le Roux wrote:
> My assumption is that my test app terminates before the GC has a chance to
> run.
> To test this:
>
>- I run node with the --expose-gc option
>- I call global.gc() at the end of my test app
>
> In this case, the destructor of my
Thank you!
Great help here. Amazing folks!
On Nov 17, 2017 6:21 PM, "J Decker" wrote:
>
>
> On Fri, Nov 17, 2017 at 7:25 AM, Jean-Marc Le Roux <
> jeanmarc.ler...@aerys.in> wrote:
>
>> My assumption is that my test app terminates before the GC has a chance
>> to run.
>> To test this:
>>
>>-
13 matches
Mail list logo