summaryrefslogtreecommitdiffstats
path: root/core/dictionary.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /core/dictionary.cpp
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
downloadredot-engine-0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a.tar.gz
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'core/dictionary.cpp')
-rw-r--r--core/dictionary.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index bc3b792bd5..bc8e795da7 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -35,13 +35,11 @@
#include "core/variant.h"
struct DictionaryPrivate {
-
SafeRefCount refcount;
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> variant_map;
};
void Dictionary::get_key_list(List<Variant> *p_keys) const {
-
if (_p->variant_map.empty())
return;
@@ -51,7 +49,6 @@ void Dictionary::get_key_list(List<Variant> *p_keys) const {
}
Variant Dictionary::get_key_at_index(int p_index) const {
-
int index = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
if (index == p_index) {
@@ -64,7 +61,6 @@ Variant Dictionary::get_key_at_index(int p_index) const {
}
Variant Dictionary::get_value_at_index(int p_index) const {
-
int index = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
if (index == p_index) {
@@ -77,16 +73,13 @@ Variant Dictionary::get_value_at_index(int p_index) const {
}
Variant &Dictionary::operator[](const Variant &p_key) {
-
return _p->variant_map[p_key];
}
const Variant &Dictionary::operator[](const Variant &p_key) const {
-
return _p->variant_map[p_key];
}
const Variant *Dictionary::getptr(const Variant &p_key) const {
-
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key);
if (!E)
@@ -95,7 +88,6 @@ const Variant *Dictionary::getptr(const Variant &p_key) const {
}
Variant *Dictionary::getptr(const Variant &p_key) {
-
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.find(p_key);
if (!E)
@@ -104,7 +96,6 @@ Variant *Dictionary::getptr(const Variant &p_key) {
}
Variant Dictionary::get_valid(const Variant &p_key) const {
-
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key);
if (!E)
@@ -122,16 +113,13 @@ Variant Dictionary::get(const Variant &p_key, const Variant &p_default) const {
}
int Dictionary::size() const {
-
return _p->variant_map.size();
}
bool Dictionary::empty() const {
-
return !_p->variant_map.size();
}
bool Dictionary::has(const Variant &p_key) const {
-
return _p->variant_map.has(p_key);
}
@@ -145,22 +133,18 @@ bool Dictionary::has_all(const Array &p_keys) const {
}
bool Dictionary::erase(const Variant &p_key) {
-
return _p->variant_map.erase(p_key);
}
bool Dictionary::operator==(const Dictionary &p_dictionary) const {
-
return _p == p_dictionary._p;
}
bool Dictionary::operator!=(const Dictionary &p_dictionary) const {
-
return _p != p_dictionary._p;
}
void Dictionary::_ref(const Dictionary &p_from) const {
-
//make a copy first (thread safe)
if (!p_from._p->refcount.ref())
return; // couldn't copy
@@ -176,12 +160,10 @@ void Dictionary::_ref(const Dictionary &p_from) const {
}
void Dictionary::clear() {
-
_p->variant_map.clear();
}
void Dictionary::_unref() const {
-
ERR_FAIL_COND(!_p);
if (_p->refcount.unref()) {
memdelete(_p);
@@ -189,7 +171,6 @@ void Dictionary::_unref() const {
_p = nullptr;
}
uint32_t Dictionary::hash() const {
-
uint32_t h = hash_djb2_one_32(Variant::DICTIONARY);
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
@@ -201,7 +182,6 @@ uint32_t Dictionary::hash() const {
}
Array Dictionary::keys() const {
-
Array varr;
if (_p->variant_map.empty())
return varr;
@@ -218,7 +198,6 @@ Array Dictionary::keys() const {
}
Array Dictionary::values() const {
-
Array varr;
if (_p->variant_map.empty())
return varr;
@@ -235,7 +214,6 @@ Array Dictionary::values() const {
}
const Variant *Dictionary::next(const Variant *p_key) const {
-
if (p_key == nullptr) {
// caller wants to get the first element
if (_p->variant_map.front())
@@ -250,7 +228,6 @@ const Variant *Dictionary::next(const Variant *p_key) const {
}
Dictionary Dictionary::duplicate(bool p_deep) const {
-
Dictionary n;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
@@ -261,7 +238,6 @@ Dictionary Dictionary::duplicate(bool p_deep) const {
}
void Dictionary::operator=(const Dictionary &p_dictionary) {
-
_ref(p_dictionary);
}
@@ -275,11 +251,9 @@ Dictionary::Dictionary(const Dictionary &p_from) {
}
Dictionary::Dictionary() {
-
_p = memnew(DictionaryPrivate);
_p->refcount.init();
}
Dictionary::~Dictionary() {
-
_unref();
}