Skip to content

Commit

Permalink
view: use a name that doesn't drive me crazy when I search for it
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Dec 7, 2023
1 parent a927d6d commit cd24c0a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions natvis/entt/entity.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@
</Expand>
</Type>
<Type Name="entt::basic_view&lt;*&gt;">
<DisplayString Condition="view != nullptr">{{ size_hint={ view->packed.size() } }}</DisplayString>
<DisplayString Condition="leading != nullptr">{{ size_hint={ leading->packed.size() } }}</DisplayString>
<DisplayString>{{ size_hint=0 }}</DisplayString>
<Expand>
<Item Name="[pools]" Optional="true">pools,na</Item>
<Item Name="[filter]" Optional="true">filter,na</Item>
<Item Name="[handle]" Condition="view != nullptr">view,na</Item>
<Item Name="[handle]" Condition="leading != nullptr">leading,na</Item>
</Expand>
</Type>
<Type Name="entt::basic_runtime_view&lt;*&gt;">
Expand Down
74 changes: 37 additions & 37 deletions src/entt/entity/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,26 +220,26 @@ class basic_common_view {

protected:
void use(const std::size_t pos) noexcept {
if(view) {
view = pools[pos];
if(leading) {
leading = pools[pos];
opaque_check_set();
}
}

void opaque_check_set() noexcept {
for(size_type pos{}, curr{}; pos < Get; ++pos) {
if(pools[pos] != view) {
if(pools[pos] != leading) {
check[curr++] = pools[pos];
}
}
}

void unchecked_refresh() noexcept {
view = pools[0u];
leading = pools[0u];

for(size_type pos{1u}; pos < Get; ++pos) {
if(pools[pos]->size() < view->size()) {
view = pools[pos];
if(pools[pos]->size() < leading->size()) {
leading = pools[pos];
}
}

Expand All @@ -258,7 +258,7 @@ class basic_common_view {

/*! @brief Updates the internal leading view if required. */
void refresh() noexcept {
size_type pos = (view != nullptr) * Get;
size_type pos = (leading != nullptr) * Get;
for(; pos < Get && pools[pos] != nullptr; ++pos) {}

if(pos == Get) {
Expand All @@ -271,15 +271,15 @@ class basic_common_view {
* @return The leading storage of the view.
*/
[[nodiscard]] const common_type *handle() const noexcept {
return view;
return leading;
}

/**
* @brief Estimates the number of entities iterated by the view.
* @return Estimated number of entities iterated by the view.
*/
[[nodiscard]] size_type size_hint() const noexcept {
return view ? view->size() : size_type{};
return leading ? leading->size() : size_type{};
}

/**
Expand All @@ -290,15 +290,15 @@ class basic_common_view {
* @return An iterator to the first entity of the view.
*/
[[nodiscard]] iterator begin() const noexcept {
return view ? iterator{view->begin(0), view->end(0), check, filter} : iterator{};
return leading ? iterator{leading->begin(0), leading->end(0), check, filter} : iterator{};
}

/**
* @brief Returns an iterator that is past the last entity of the view.
* @return An iterator to the entity following the last entity of the view.
*/
[[nodiscard]] iterator end() const noexcept {
return view ? iterator{view->end(0), view->end(0), check, filter} : iterator{};
return leading ? iterator{leading->end(0), leading->end(0), check, filter} : iterator{};
}

/**
Expand All @@ -317,9 +317,9 @@ class basic_common_view {
* otherwise.
*/
[[nodiscard]] entity_type back() const noexcept {
if(view) {
auto it = view->rbegin(0);
const auto last = view->rend(0);
if(leading) {
auto it = leading->rbegin(0);
const auto last = leading->rend(0);
for(; it != last && !contains(*it); ++it) {}
return it == last ? null : *it;
}
Expand All @@ -334,15 +334,15 @@ class basic_common_view {
* iterator otherwise.
*/
[[nodiscard]] iterator find(const entity_type entt) const noexcept {
return contains(entt) ? iterator{view->find(entt), view->end(), check, filter} : end();
return contains(entt) ? iterator{leading->find(entt), leading->end(), check, filter} : end();
}

/**
* @brief Checks if a view is fully initialized.
* @return True if the view is fully initialized, false otherwise.
*/
[[nodiscard]] explicit operator bool() const noexcept {
return (view != nullptr) && internal::fully_initialized(filter.data(), filter.size());
return (leading != nullptr) && internal::fully_initialized(filter.data(), filter.size());
}

/**
Expand All @@ -351,9 +351,9 @@ class basic_common_view {
* @return True if the view contains the given entity, false otherwise.
*/
[[nodiscard]] bool contains(const entity_type entt) const noexcept {
if(view) {
const auto idx = view->find(entt).index();
return (!(idx < 0 || idx > view->begin(0).index())) && internal::all_of(check.data(), check.size(), entt) && internal::none_of(filter.data(), filter.size(), entt);
if(leading) {
const auto idx = leading->find(entt).index();
return (!(idx < 0 || idx > leading->begin(0).index())) && internal::all_of(check.data(), check.size(), entt) && internal::none_of(filter.data(), filter.size(), entt);
}

return false;
Expand All @@ -363,7 +363,7 @@ class basic_common_view {
std::array<const common_type *, Get> pools{};
std::array<const common_type *, Exclude> filter{};
std::array<const common_type *, Get - 1u> check{};
const common_type *view{};
const common_type *leading{};
};

/**
Expand Down Expand Up @@ -636,23 +636,23 @@ struct basic_storage_view {
* @return The leading storage of the view.
*/
[[nodiscard]] const common_type *handle() const noexcept {
return view;
return leading;
}

/**
* @brief Returns the number of entities that have the given component.
* @return Number of entities that have the given component.
*/
[[nodiscard]] size_type size() const noexcept {
return view ? view->size() : size_type{};
return leading ? leading->size() : size_type{};
}

/**
* @brief Checks whether a view is empty.
* @return True if the view is empty, false otherwise.
*/
[[nodiscard]] bool empty() const noexcept {
return !view || view->empty();
return !leading || leading->empty();
}

/**
Expand All @@ -663,15 +663,15 @@ struct basic_storage_view {
* @return An iterator to the first entity of the view.
*/
[[nodiscard]] iterator begin() const noexcept {
return view ? view->begin() : iterator{};
return leading ? leading->begin() : iterator{};
}

/**
* @brief Returns an iterator that is past the last entity of the view.
* @return An iterator to the entity following the last entity of the view.
*/
[[nodiscard]] iterator end() const noexcept {
return view ? view->end() : iterator{};
return leading ? leading->end() : iterator{};
}

/**
Expand All @@ -682,7 +682,7 @@ struct basic_storage_view {
* @return An iterator to the first entity of the reversed view.
*/
[[nodiscard]] reverse_iterator rbegin() const noexcept {
return view ? view->rbegin() : reverse_iterator{};
return leading ? leading->rbegin() : reverse_iterator{};
}

/**
Expand All @@ -692,7 +692,7 @@ struct basic_storage_view {
* reversed view.
*/
[[nodiscard]] reverse_iterator rend() const noexcept {
return view ? view->rend() : reverse_iterator{};
return leading ? leading->rend() : reverse_iterator{};
}

/**
Expand All @@ -701,7 +701,7 @@ struct basic_storage_view {
* otherwise.
*/
[[nodiscard]] entity_type front() const noexcept {
return empty() ? null : *view->begin();
return empty() ? null : *leading->begin();
}

/**
Expand All @@ -710,7 +710,7 @@ struct basic_storage_view {
* otherwise.
*/
[[nodiscard]] entity_type back() const noexcept {
return empty() ? null : *view->rbegin();
return empty() ? null : *leading->rbegin();
}

/**
Expand All @@ -720,7 +720,7 @@ struct basic_storage_view {
* iterator otherwise.
*/
[[nodiscard]] iterator find(const entity_type entt) const noexcept {
return view ? view->find(entt) : iterator{};
return leading ? leading->find(entt) : iterator{};
}

/**
Expand All @@ -737,7 +737,7 @@ struct basic_storage_view {
* @return True if the view is fully initialized, false otherwise.
*/
[[nodiscard]] explicit operator bool() const noexcept {
return (view != nullptr);
return (leading != nullptr);
}

/**
Expand All @@ -746,11 +746,11 @@ struct basic_storage_view {
* @return True if the view contains the given entity, false otherwise.
*/
[[nodiscard]] bool contains(const entity_type entt) const noexcept {
return view && view->contains(entt);
return leading && leading->contains(entt);
}

protected:
const common_type *view{};
const common_type *leading{};
};

/**
Expand Down Expand Up @@ -791,7 +791,7 @@ class basic_view<get_t<Get>, exclude_t<>, std::void_t<std::enable_if_t<!Get::tra
*/
basic_view(Get &value) noexcept
: basic_view{} {
this->view = &value;
this->leading = &value;
}

/**
Expand Down Expand Up @@ -820,7 +820,7 @@ class basic_view<get_t<Get>, exclude_t<>, std::void_t<std::enable_if_t<!Get::tra
template<std::size_t Index>
[[nodiscard]] auto *storage() const noexcept {
static_assert(Index == 0u, "Index out of bounds");
return static_cast<Get *>(const_cast<constness_as_t<common_type, Get> *>(this->view));
return static_cast<Get *>(const_cast<constness_as_t<common_type, Get> *>(this->leading));
}

/**
Expand All @@ -839,7 +839,7 @@ class basic_view<get_t<Get>, exclude_t<>, std::void_t<std::enable_if_t<!Get::tra
template<std::size_t Index>
void storage(Get &elem) noexcept {
static_assert(Index == 0u, "Index out of bounds");
this->view = &elem;
this->leading = &elem;
}

/**
Expand Down Expand Up @@ -931,7 +931,7 @@ class basic_view<get_t<Get>, exclude_t<>, std::void_t<std::enable_if_t<!Get::tra
* @return An iterable object to use to _visit_ the view.
*/
[[nodiscard]] iterable each() const noexcept {
return this->view ? storage()->each() : iterable{};
return this->leading ? storage()->each() : iterable{};
}

/**
Expand Down

0 comments on commit cd24c0a

Please sign in to comment.