From 270c6392d41ca888e309f3c2879fd9ac517f56e2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 8 Feb 2023 11:23:44 +0100 Subject: [PATCH 1/5] Dictionary#Remove(): remove unused bool overrideFrozen --- lib/base/dictionary.cpp | 10 ++++------ lib/base/dictionary.hpp | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index 435df3159..b8ec3a5e1 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -141,13 +141,12 @@ Dictionary::Iterator Dictionary::End() * Removes the item specified by the iterator from the dictionary. * * @param it The iterator. - * @param overrideFrozen Whether to allow modifying frozen dictionaries. */ -void Dictionary::Remove(Dictionary::Iterator it, bool overrideFrozen) +void Dictionary::Remove(Dictionary::Iterator it) { ASSERT(OwnsLock()); - if (m_Frozen && !overrideFrozen) + if (m_Frozen) BOOST_THROW_EXCEPTION(std::invalid_argument("Dictionary must not be modified.")); m_Data.erase(it); @@ -157,13 +156,12 @@ void Dictionary::Remove(Dictionary::Iterator it, bool overrideFrozen) * Removes the specified key from the dictionary. * * @param key The key. - * @param overrideFrozen Whether to allow modifying frozen dictionaries. */ -void Dictionary::Remove(const String& key, bool overrideFrozen) +void Dictionary::Remove(const String& key) { ObjectLock olock(this); - if (m_Frozen && !overrideFrozen) + if (m_Frozen) BOOST_THROW_EXCEPTION(std::invalid_argument("Dictionary must not be modified.")); Dictionary::Iterator it; diff --git a/lib/base/dictionary.hpp b/lib/base/dictionary.hpp index 227868751..298cdf22c 100644 --- a/lib/base/dictionary.hpp +++ b/lib/base/dictionary.hpp @@ -49,9 +49,9 @@ public: size_t GetLength() const; - void Remove(const String& key, bool overrideFrozen = false); + void Remove(const String& key); - void Remove(Iterator it, bool overrideFrozen = false); + void Remove(Iterator it); void Clear(bool overrideFrozen = false); From cd78da13d3480fd412c9bfb5bac96042410ae483 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 8 Feb 2023 11:26:44 +0100 Subject: [PATCH 2/5] Dictionary#Clear(): remove unused bool overrideFrozen --- lib/base/dictionary.cpp | 6 ++---- lib/base/dictionary.hpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index b8ec3a5e1..7199b212b 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -175,14 +175,12 @@ void Dictionary::Remove(const String& key) /** * Removes all dictionary items. - * - * @param overrideFrozen Whether to allow modifying frozen dictionaries. */ -void Dictionary::Clear(bool overrideFrozen) +void Dictionary::Clear() { ObjectLock olock(this); - if (m_Frozen && !overrideFrozen) + if (m_Frozen) BOOST_THROW_EXCEPTION(std::invalid_argument("Dictionary must not be modified.")); m_Data.clear(); diff --git a/lib/base/dictionary.hpp b/lib/base/dictionary.hpp index 298cdf22c..4e030ff92 100644 --- a/lib/base/dictionary.hpp +++ b/lib/base/dictionary.hpp @@ -53,7 +53,7 @@ public: void Remove(Iterator it); - void Clear(bool overrideFrozen = false); + void Clear(); void CopyTo(const Dictionary::Ptr& dest) const; Dictionary::Ptr ShallowClone() const; From e9846f1827365bfe9dba02b2230a92b83a2b88de Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 8 Feb 2023 11:50:40 +0100 Subject: [PATCH 3/5] ScriptGlobal::Set(): remove unused bool overrideFrozen --- lib/base/scriptglobal.cpp | 4 ++-- lib/base/scriptglobal.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/base/scriptglobal.cpp b/lib/base/scriptglobal.cpp index f730612b1..7a6aada16 100644 --- a/lib/base/scriptglobal.cpp +++ b/lib/base/scriptglobal.cpp @@ -31,7 +31,7 @@ Value ScriptGlobal::Get(const String& name, const Value *defaultValue) return result; } -void ScriptGlobal::Set(const String& name, const Value& value, bool overrideFrozen) +void ScriptGlobal::Set(const String& name, const Value& value) { std::vector tokens = name.Split("."); @@ -59,7 +59,7 @@ void ScriptGlobal::Set(const String& name, const Value& value, bool overrideFroz } } - parent->SetFieldByName(tokens[tokens.size() - 1], value, overrideFrozen, DebugInfo()); + parent->SetFieldByName(tokens[tokens.size() - 1], value, false, DebugInfo()); } } diff --git a/lib/base/scriptglobal.hpp b/lib/base/scriptglobal.hpp index c31cdcdf6..f349b7b01 100644 --- a/lib/base/scriptglobal.hpp +++ b/lib/base/scriptglobal.hpp @@ -18,7 +18,7 @@ class ScriptGlobal { public: static Value Get(const String& name, const Value *defaultValue = nullptr); - static void Set(const String& name, const Value& value, bool overrideFrozen = false); + static void Set(const String& name, const Value& value); static void SetConst(const String& name, const Value& value); static bool Exists(const String& name); From e61b380808b8b63dc14037d0bcebbcde1242dbe3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 10 Feb 2023 15:53:30 +0100 Subject: [PATCH 4/5] Call Namespace#Set(), not #SetFieldByName() Namespace#SetFieldByName() calls #Set() anyway. --- lib/base/scriptglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base/scriptglobal.cpp b/lib/base/scriptglobal.cpp index 7a6aada16..a280aef20 100644 --- a/lib/base/scriptglobal.cpp +++ b/lib/base/scriptglobal.cpp @@ -59,7 +59,7 @@ void ScriptGlobal::Set(const String& name, const Value& value) } } - parent->SetFieldByName(tokens[tokens.size() - 1], value, false, DebugInfo()); + parent->Set(tokens[tokens.size() - 1], value, false, DebugInfo()); } } From f3f2c943c77623767f752eba61f9c60225673b8f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 10 Feb 2023 15:55:10 +0100 Subject: [PATCH 5/5] ScriptGlobal::Set(): don't explicitly give Namespace#Set() its default values --- lib/base/scriptglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base/scriptglobal.cpp b/lib/base/scriptglobal.cpp index a280aef20..0a4287efb 100644 --- a/lib/base/scriptglobal.cpp +++ b/lib/base/scriptglobal.cpp @@ -59,7 +59,7 @@ void ScriptGlobal::Set(const String& name, const Value& value) } } - parent->Set(tokens[tokens.size() - 1], value, false, DebugInfo()); + parent->Set(tokens[tokens.size() - 1], value); } }