From e7c5b9fb0f75b1e75acf7c99eded5f7b697cdc60 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 3 May 2023 17:38:30 -0400 Subject: SL-19647: Eliminate LLSDArray entirely. Newer C++ compilers have different semantics around LLSDArray's special copy constructor, which was essential to proper LLSD nesting. In short, we can no longer trust LLSDArray to behave correctly. Now that we have variadic functions, get rid of LLSDArray and replace every reference with llsd::array(). --- indra/llcommon/llsdutil.h | 69 ----------------------------------------------- 1 file changed, 69 deletions(-) (limited to 'indra/llcommon/llsdutil.h') diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h index 1321615805..372278c51a 100644 --- a/indra/llcommon/llsdutil.h +++ b/indra/llcommon/llsdutil.h @@ -191,75 +191,6 @@ LLSD& drill_ref( LLSD& blob, const LLSD& path); } -/***************************************************************************** -* LLSDArray -*****************************************************************************/ -/** - * Construct an LLSD::Array inline, with implicit conversion to LLSD. Usage: - * - * @code - * void somefunc(const LLSD&); - * ... - * somefunc(LLSDArray("text")(17)(3.14)); - * @endcode - * - * For completeness, LLSDArray() with no args constructs an empty array, so - * LLSDArray()("text")(17)(3.14) produces an array equivalent to the - * above. But for most purposes, LLSD() is already equivalent to an empty - * array, and if you explicitly want an empty isArray(), there's - * LLSD::emptyArray(). However, supporting a no-args LLSDArray() constructor - * follows the principle of least astonishment. - */ -class LLSDArray -{ -public: - LLSDArray(): - _data(LLSD::emptyArray()) - {} - - /** - * Need an explicit copy constructor. Consider the following: - * - * @code - * LLSD array_of_arrays(LLSDArray(LLSDArray(17)(34)) - * (LLSDArray("x")("y"))); - * @endcode - * - * The coder intends to construct [[17, 34], ["x", "y"]]. - * - * With the compiler's implicit copy constructor, s/he gets instead - * [17, 34, ["x", "y"]]. - * - * The expression LLSDArray(17)(34) constructs an LLSDArray with those two - * values. The reader assumes it should be converted to LLSD, as we always - * want with LLSDArray, before passing it to the @em outer LLSDArray - * constructor! This copy constructor makes that happen. - */ - LLSDArray(const LLSDArray& inner): - _data(LLSD::emptyArray()) - { - _data.append(inner); - } - - LLSDArray(const LLSD& value): - _data(LLSD::emptyArray()) - { - _data.append(value); - } - - LLSDArray& operator()(const LLSD& value) - { - _data.append(value); - return *this; - } - - operator LLSD() const { return _data; } - LLSD get() const { return _data; } - -private: - LLSD _data; -}; - namespace llsd { -- cgit v1.2.3