From cdb607f20217c7d355d4984bc35820a42d4f12d5 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Mon, 22 Feb 2021 09:39:09 -0800 Subject: [PATCH] Add comments on confusing "simdjson_unused" --- include/simdjson/generic/ondemand/array-inl.h | 2 ++ include/simdjson/generic/ondemand/object-inl.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/simdjson/generic/ondemand/array-inl.h b/include/simdjson/generic/ondemand/array-inl.h index 048ab356..4b78851d 100644 --- a/include/simdjson/generic/ondemand/array-inl.h +++ b/include/simdjson/generic/ondemand/array-inl.h @@ -46,6 +46,8 @@ simdjson_really_inline array::array(const value_iterator &_iter) noexcept } simdjson_really_inline simdjson_result array::start(value_iterator &iter) noexcept { + // We don't need to know if the array is empty to start iteration, but we do want to know if there + // is an error--thus `simdjson_unused`. simdjson_unused bool has_value; SIMDJSON_TRY( iter.start_array().get(has_value) ); return array(iter); diff --git a/include/simdjson/generic/ondemand/object-inl.h b/include/simdjson/generic/ondemand/object-inl.h index 0789b1b6..fa689590 100644 --- a/include/simdjson/generic/ondemand/object-inl.h +++ b/include/simdjson/generic/ondemand/object-inl.h @@ -34,6 +34,8 @@ simdjson_really_inline simdjson_result object::find_field(const std::stri } simdjson_really_inline simdjson_result object::start(value_iterator &iter) noexcept { + // We don't need to know if the object is empty to start iteration, but we do want to know if there + // is an error--thus `simdjson_unused`. simdjson_unused bool has_value; SIMDJSON_TRY( iter.start_object().get(has_value) ); return object(iter);