title: v8 create object without methods
body: <p>I'm work on next version of <a href="https://github.com/node-inspector/v8-profiler" rel="nofollow">v8-profiler</a> and now I want to simplify it. </p>
  
  <p>I see that my class (<code>ProfileNode</code>) don't needs hidden link to internal object (<code>v8::CpuProfileNode</code>), because my class don't uses internal object methods.</p>
  
  <ul>
  <li>Can I delete getter methods and replace it like the example below? </li>
  <li>Is it wrong realisation? </li>
  <li>Is it hight memory usage? </li>
  <li>Or it's OK? </li>
  </ul>
  
  <p>(I'm novice in c++ and v8 library)</p>
  
  <p>(Please ignore version uncompatibility - it's not a part of question)</p>
  
  <p>This is a part of current <a href="https://github.com/node-inspector/v8-profiler/blob/master/profile_node.cc" rel="nofollow"><code>profile_node.cc</code></a></p>
  
  <pre><code>Persistent&lt;ObjectTemplate&gt; ProfileNode::node_template_;
  
  void ProfileNode::Initialize() {
    Local&lt;ObjectTemplate&gt; tpl = NanNewLocal&lt;ObjectTemplate&gt;(ObjectTemplate::New());
    NanAssignPersistent(ObjectTemplate, node_template_, tpl);
    tpl-&gt;SetInternalFieldCount(1);
    tpl-&gt;SetAccessor(String::New("functionName"), ProfileNode::GetFunctionName);
    ...
  }
  
  NAN_GETTER(ProfileNode::GetFunctionName) {
    NanScope();
    Local&lt;Object&gt; self = args.Holder();
    void* ptr = NanGetInternalFieldPointer(self, 0);
    Handle&lt;String&gt; fname = static_cast&lt;CpuProfileNode*&gt;(ptr)-&gt;GetFunctionName();
    NanReturnValue(fname);
  }
  
  ...
  
  Handle&lt;Value&gt; ProfileNode::New(const CpuProfileNode* node) {
    NanScope();
  
    if (node_template_.IsEmpty()) {
      ProfileNode::Initialize();
    }
  
    if(!node) {
      return Undefined();
    }
    else {
      Local&lt;Object&gt; obj = NanPersistentToLocal(node_template_)-&gt;NewInstance();
      NanSetInternalFieldPointer(obj, 0, const_cast&lt;CpuProfileNode*&gt;(node));
      return obj;
    }
  }
  </code></pre>
  
  <p>After refactoring</p>
  
  <pre><code>//ProfileNode::Initialize deleted
  //ProfileNode::GetFunctionName deleted
  
  Handle&lt;Value&gt; ProfileNode::New(const CpuProfileNode* node) {
    NanScope();
  
    if(!node) {
      return NanUndefined();
    }
    else {
      //Create new simplest object, instead of new instance of object template
      Local&lt;Object&gt; obj = NanNew&lt;Object&gt;();
      //Append the value to this object
      obj-&gt;Set(String::New("functionName"), node-&gt;GetFunctionName());
      //Delete internal link.
      //NanSetInternalFieldPointer(obj, 0, const_cast&lt;CpuProfileNode*&gt;(node));
      return obj;
    }
  }
  </code></pre>