用于创建优化属性键的函数
¥Functions to create optimized property keys
许多 JavaScript 引擎(包括 V8)使用内部化字符串作为键来设置和获取属性值。他们通常使用哈希表来创建和查找此类字符串。虽然它增加了每个键创建的一些成本,但它通过启用字符串指针而不是整个字符串的比较来提高性能。
¥Many JavaScript engines including V8 use internalized strings as keys to set and get property values. They typically use a hash table to create and lookup such strings. While it adds some cost per key creation, it improves the performance after that by enabling comparison of string pointers instead of the whole strings.
如果打算将新的 JavaScript 字符串用作属性键,那么对于某些 JavaScript 引擎来说,使用本节中的函数会更有效率。否则,请使用 napi_create_string_utf8
或 node_api_create_external_string_utf8
系列函数,因为使用属性键创建方法创建/存储字符串可能会产生额外的开销。
¥If a new JavaScript string is intended to be used as a property key, then for
some JavaScript engines it will be more efficient to use the functions in this
section. Otherwise, use the napi_create_string_utf8
or
node_api_create_external_string_utf8
series functions as there may be
additional overhead in creating/storing strings with the property key
creation methods.