From 3586fc4910c160fd3ede945447b0c05b618359d4 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 17 Jun 2020 18:49:22 +0000 Subject: [PATCH] Fix for issue 680 --- include/simdjson/dom/array.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/simdjson/dom/array.h b/include/simdjson/dom/array.h index 44ef4bb4..62a48c9e 100644 --- a/include/simdjson/dom/array.h +++ b/include/simdjson/dom/array.h @@ -80,8 +80,18 @@ public: inline simdjson_result at(const std::string_view &json_pointer) const noexcept; /** - * Get the value at the given index. + * Get the value at the given index. This function has linear-time complexity and + * is equivalent to the following: + * + * size_t i=0; + * for (auto element : *this) { + * if (i == index) { return element; } + * i++; + * } + * return INDEX_OUT_OF_BOUNDS; * + * Avoid calling the at() function repeatedly. + * * @return The value at the given index, or: * - INDEX_OUT_OF_BOUNDS if the array index is larger than an array length */