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

Skip unnecessary writes in default impl for modifyGet #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tbekas
Copy link
Contributor

@tbekas tbekas commented Aug 14, 2024

This is an optimization only. No functionality is changed, therefore no need to update any tests.

@tbekas tbekas requested review from dryajov, gmega and benbierens August 14, 2024 16:02
benbierens
benbierens previously approved these changes Aug 15, 2024
Copy link
Contributor

@benbierens benbierens left a comment

Choose a reason for hiding this comment

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

👍

@@ -37,6 +37,10 @@ proc defaultModifyGetImpl*(
except CatchableError as err:
return failure(err)

if maybeCurrentData == maybeNewData:
Copy link
Member

@gmega gmega Aug 15, 2024

Choose a reason for hiding this comment

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

🔴 Well technically you should be able to test for this (the absence of a write), and I'd argue you should test for it as otherwise you can't know if your optimization is actually working (which is something we care about, as otherwise there'd be no point in putting it there), no matter how convincing the code looks. 🙂

I'm wiling to let this pass - against my own best judgement - if you tell me that writing such a test is complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that skipping writes is not such a crucial feature that would justify having a test that verify if something was called or not called (one of the worst kinds of tests imo), but I've added such test anyway.

@tbekas tbekas force-pushed the skip-unnecessary-write branch 3 times, most recently from 9bcef1a to e1046b6 Compare August 28, 2024 14:40
@tbekas tbekas force-pushed the skip-unnecessary-write branch from e1046b6 to c151f93 Compare August 28, 2024 14:50
Copy link
Contributor

@benbierens benbierens left a comment

Choose a reason for hiding this comment

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

I like it

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

Successfully merging this pull request may close these issues.

3 participants