You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Remove unneeded read_only check for Array const operator.
This commit is contained in:
@@ -88,11 +88,11 @@ Array::Iterator Array::end() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Array::ConstIterator Array::begin() const {
|
Array::ConstIterator Array::begin() const {
|
||||||
return ConstIterator(_p->array.ptr(), _p->read_only);
|
return ConstIterator(_p->array.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Array::ConstIterator Array::end() const {
|
Array::ConstIterator Array::end() const {
|
||||||
return ConstIterator(_p->array.ptr() + _p->array.size(), _p->read_only);
|
return ConstIterator(_p->array.ptr() + _p->array.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant &Array::operator[](int p_idx) {
|
Variant &Array::operator[](int p_idx) {
|
||||||
@@ -104,10 +104,6 @@ Variant &Array::operator[](int p_idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Variant &Array::operator[](int p_idx) const {
|
const Variant &Array::operator[](int p_idx) const {
|
||||||
if (unlikely(_p->read_only)) {
|
|
||||||
*_p->read_only = _p->array[p_idx];
|
|
||||||
return *_p->read_only;
|
|
||||||
}
|
|
||||||
return _p->array[p_idx];
|
return _p->array[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,21 +56,19 @@ public:
|
|||||||
_FORCE_INLINE_ bool operator==(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr; }
|
_FORCE_INLINE_ bool operator==(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr; }
|
||||||
_FORCE_INLINE_ bool operator!=(const ConstIterator &p_other) const { return element_ptr != p_other.element_ptr; }
|
_FORCE_INLINE_ bool operator!=(const ConstIterator &p_other) const { return element_ptr != p_other.element_ptr; }
|
||||||
|
|
||||||
_FORCE_INLINE_ ConstIterator(const Variant *p_element_ptr, Variant *p_read_only = nullptr) :
|
_FORCE_INLINE_ ConstIterator(const Variant *p_element_ptr) :
|
||||||
element_ptr(p_element_ptr), read_only(p_read_only) {}
|
element_ptr(p_element_ptr) {}
|
||||||
_FORCE_INLINE_ ConstIterator() {}
|
_FORCE_INLINE_ ConstIterator() {}
|
||||||
_FORCE_INLINE_ ConstIterator(const ConstIterator &p_other) :
|
_FORCE_INLINE_ ConstIterator(const ConstIterator &p_other) :
|
||||||
element_ptr(p_other.element_ptr), read_only(p_other.read_only) {}
|
element_ptr(p_other.element_ptr) {}
|
||||||
|
|
||||||
_FORCE_INLINE_ ConstIterator &operator=(const ConstIterator &p_other) {
|
_FORCE_INLINE_ ConstIterator &operator=(const ConstIterator &p_other) {
|
||||||
element_ptr = p_other.element_ptr;
|
element_ptr = p_other.element_ptr;
|
||||||
read_only = p_other.read_only;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Variant *element_ptr = nullptr;
|
const Variant *element_ptr = nullptr;
|
||||||
Variant *read_only = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Iterator {
|
struct Iterator {
|
||||||
@@ -96,7 +94,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator ConstIterator() const {
|
operator ConstIterator() const {
|
||||||
return ConstIterator(element_ptr, read_only);
|
return ConstIterator(element_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -997,18 +997,10 @@ Array::Iterator &Array::Iterator::operator--() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Variant &Array::ConstIterator::operator*() const {
|
const Variant &Array::ConstIterator::operator*() const {
|
||||||
if (unlikely(read_only)) {
|
|
||||||
*read_only = *element_ptr;
|
|
||||||
return *read_only;
|
|
||||||
}
|
|
||||||
return *element_ptr;
|
return *element_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Variant *Array::ConstIterator::operator->() const {
|
const Variant *Array::ConstIterator::operator->() const {
|
||||||
if (unlikely(read_only)) {
|
|
||||||
*read_only = *element_ptr;
|
|
||||||
return read_only;
|
|
||||||
}
|
|
||||||
return element_ptr;
|
return element_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user