Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe wrong usage of UTILS_UNLIKELY #8325

Open
OvJat opened this issue Dec 23, 2024 · 0 comments
Open

Maybe wrong usage of UTILS_UNLIKELY #8325

OvJat opened this issue Dec 23, 2024 · 0 comments

Comments

@OvJat
Copy link

OvJat commented Dec 23, 2024

When reading the source code Engine.cpp,I find some wrong usage of UTILS_UNLIKELY, ex:
file: Engine.cpp , line: 805

template<typename T, typename ... ARGS>
inline T* FEngine::create(ResourceList<T>& list,
        typename T::Builder const& builder, ARGS&& ... args) noexcept {
    T* p = mHeapAllocator.make<T>(*this, builder, std::forward<ARGS>(args)...);
    if (UTILS_UNLIKELY(p)) { // this should never happen  <<<< THIS LINE IS WRONG !!!!!
        list.insert(p);
    }
    return p;
}

In my opinion, we should replace UTILS_UNLIKELY with UTILS_LIKELY, and the comment: "this should always happen".
There are many others like this in file "Engine.cpp".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant