MONDAY, JULY 13, 2026
c++ Performance Win
C++: Avoid double resolves_to_fixed_type_p call
Optimizes type resolution by avoiding redundant function calls in C++ typeid handling.
This change optimizes the C++ typeid handling by avoiding a redundant call to resolves_to_fixed_type_p. By ensuring the typeid_evaluated_p function only calls this check once, it improves efficiency and simplifies the code.
In Details
The typeid_evaluated_p function in rtti.cc previously called resolves_to_fixed_type_p twice. This commit modifies typeid_evaluated_p to take a non-null out-parameter and makes a single call to resolves_to_fixed_type_p within build_typeid, eliminating the redundant check and improving performance.
For Context
- resolves_to_fixed_type_p
- A function that checks if a given type can be resolved to a fixed, unchanging type. This is important for compile-time evaluation and type safety.
- typeid
- A C++ operator that returns a reference to the run-time type information (RTTI) object for a given expression. This information can be used to determine the type of an object at runtime.
- RTTI
- Run-Time Type Information. A C++ feature that allows a program to determine the type of an object at runtime. It is typically used via the
typeidoperator anddynamic_cast.