From 47b9cbc71cbd2381f24ca72ffab345ce9be5c8cf Mon Sep 17 00:00:00 2001 From: lemire Date: Thu, 2 Mar 2023 00:31:23 +0000 Subject: [PATCH] deploy: 75240ad8e167f5c6cc1752e3c2b9499194a6af31 --- md_doc_basics.html | 6 +++--- navtreedata.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/md_doc_basics.html b/md_doc_basics.html index 34d91c8bd..c99ec0611 100644 --- a/md_doc_basics.html +++ b/md_doc_basics.html @@ -104,7 +104,7 @@ $(document).ready(function(){initNavTree('md_doc_basics.html',''); initResizable
  • Parser, Document and JSON Scope
  • -
  • std::string_view
  • +
  • string_view
  • Using the Parsed JSON @@ -222,7 +222,7 @@ Parser, Document and JSON Scope

    For best performance, a parser instance should be reused over several files: otherwise you will needlessly reallocate memory, an expensive process. It is also possible to avoid entirely memory allocations during parsing when using simdjson. See our performance notes for details.

    If you need to have several documents active at once, you should have several parser instances.

    -std::string_view

    +string_view

    The simdjson library builds on compilers supporting the C++11 standard. It is also a strict requirement: we have no plan to support older C++ compilers.

    We represent parsed Unicode (UTF-8) strings in simdjson using the std::string_view class. It avoids the need to copy the data, as would be necessary with the std::string class. It also avoids the pitfalls of null-terminated C strings. It makes it easier for our users to copy the data into their own favorite class instances (e.g., alternatives to std::string).

    A std::string_view instance is effectively just a pointer to a region in memory representing a string. In simdjson, we return std::string_view instances that either point within the input string you parsed, or to a temporary string buffer inside our parser class instances. When using std::string_view instances, it is your responsibility to ensure that std::string_view instance does not outlive the pointed-to memory (e.g., either the input buffer or the parser instance). Furthermore, some operations reset the string buffer inside our parser instances: e.g., when we parse a new document. Thus a std::string_view instance is often best viewed as a temporary string value that is tied to the document you are parsing. At the cost of some memory allocation, you may convert your std::string_view instances for long-term storage into std::string instances: std::string mycopy(view) (C++17) or std::string mycopy(view.begin(), view.end()) (prior to C++17).

    @@ -239,7 +239,7 @@ Using the Parsed JSON
  • Because On Demand is really just an iterator, you must fully consume the current object or array before accessing a sibling object or array.
  • Values can only be consumed once, you should get the values and store them if you plan to need them multiple times. You are expected to access the keys of an object just once. You are expected to go through the values of an array just once.
  • -

    The simdjson library makes generous use of std::string_view instances. If you are unfamiliar with std::string_view in C++, make sure to read the section on std::string_view.

    +

    The simdjson library makes generous use of std::string_view instances. If you are unfamiliar with std::string_view in C++, make sure to read the section on std::string_view.

    The following specific instructions indicate how to use the JSON when exceptions are enabled, but simdjson has full, idiomatic support for users who avoid exceptions. See the simdjson error handling documentation for more.