Skip to content

Use Pure function attribute #17230

@JeremyRubin

Description

@JeremyRubin

In #17218 (comment) @ryanofsky claims that the compiler probably can't optimize certain calls like pindex->GetBlockHash().ToHex(). Using the gnu::pure (which is pretty widely supported) attribute would likely fix that & would be good documentation for functions that we don't expect to have any side effects.

Maybe we should look at the gnu::pure attribute (which have pretty wide support in gcc/clang/llvm and others, except MSVC) and noexcept, which would allow the compiler to better optimize such functions if this is an issue https://stackoverflow.com/questions/2798188/pure-const-function-attributes-in-different-compilers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions