Skip to content

Commit

Permalink
address TODO
Browse files Browse the repository at this point in the history
Summary: This is a behavior-preserving change.

Reviewed By: agampe

Differential Revision: D50821152

fbshipit-source-id: 2d324a8ba91ef5a2adc9e50f30289b66d7906ac3
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Oct 31, 2023
1 parent 37dee0f commit 8be3a87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions opt/optimize_enums/EnumTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ struct EnumUtil {
DexMethodRef* STRING_EQ_METHOD =
DexMethod::make_method("Ljava/lang/String;.equals:(Ljava/lang/Object;)Z");

InsertOnlyConcurrentMap<DexClass*, DexMethod*>
m_user_defined_tostring_method_cache;

explicit EnumUtil(const Config& config) : m_config(config) {}

void create_util_class(DexStoresVector* stores, uint32_t fields_count) {
Expand Down Expand Up @@ -314,9 +317,7 @@ struct EnumUtil {
* `Enum.toString()`. Return `nullptr` if `Enum.toString()` is not overridden.
*/
DexMethod* get_user_defined_tostring_method(DexClass* cls) {
// TODO: Don't have a *static* cache.
static InsertOnlyConcurrentMap<DexClass*, DexMethod*> cache;
return *cache
return *m_user_defined_tostring_method_cache
.get_or_create_and_assert_equal(
cls,
[&](auto*) -> DexMethod* {
Expand Down

0 comments on commit 8be3a87

Please sign in to comment.