Skip to content

Small code cleanup#10690

Merged
findepi merged 4 commits intotrinodb:masterfrom
findepi:findepi/remove-redundant-code-e63714
Jan 19, 2022
Merged

Small code cleanup#10690
findepi merged 4 commits intotrinodb:masterfrom
findepi:findepi/remove-redundant-code-e63714

Conversation

@findepi
Copy link
Copy Markdown
Member

@findepi findepi commented Jan 19, 2022

No description provided.

There is no apparent advantage in calling `getIfPresent(key)` before
calling `get(key)` on a loading cache.
@findepi findepi requested review from ebyhr and hashhar January 19, 2022 14:10
@cla-bot cla-bot bot added the cla-signed label Jan 19, 2022
Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % question (I'll get back with details)


private static <K, V> V getFromCache(LoadingCache<K, V> cache, K key)
{
V value = cache.getIfPresent(key);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC there was some mention that getIfPresent is more contention safe than get? Or was it about computeIfAbsent?

I'll check and get back.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However this doesn't seem to be in a hot path so shouldn't matter. Readability first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hashhar thanks for reminding me.
yes, i think it doesn't matter here
i think this is the thread: #9980

cc @sopel39

@findepi findepi merged commit 779d7f6 into trinodb:master Jan 19, 2022
@findepi findepi deleted the findepi/remove-redundant-code-e63714 branch January 19, 2022 20:47
@github-actions github-actions bot added this to the 369 milestone Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants