Skip to content

Conversation

@miniBill
Copy link
Collaborator

This inlines the call to Result.map in Result.Extra.andMap, because we're already pattern matching on the values, might as well do it completely and save a function call.

The performance improvements are minor, but the code size increase is also minor, so it's a tradeoff. I picked this function in particular because it's the one we use the most at work.

Benchmarks

Firefox
image
Chrome
image

@gampleman
Copy link
Collaborator

Looking at the screenshots, it doesn't look like it even particularly improves performance in most cases, no?

Also I'd suggest that in real world uses there is a fair likelihood that Result.map would get a higher level of JIT compilation because it's quite likely to be called many times, so I'd have some concerns about real world impact here as well.

@miniBill
Copy link
Collaborator Author

Eh, fair enough. I hoped for a bigger change but I guess the JIT is doing a good job

@gampleman
Copy link
Collaborator

I'm happy to merge the benchmarks to record this experiment for the future, but I don't think they support changing the implementation.

@miniBill miniBill force-pushed the result-extra-andmap-inlining branch from f1c2191 to d378f90 Compare February 26, 2025 10:59
@miniBill miniBill force-pushed the result-extra-andmap-inlining branch from d378f90 to 25b0c1c Compare February 26, 2025 11:03
@miniBill miniBill merged commit 70cf084 into elmcraft:master Feb 26, 2025
2 checks passed
@miniBill miniBill deleted the result-extra-andmap-inlining branch February 26, 2025 11:04
@miniBill
Copy link
Collaborator Author

Left only the benchmarks in and merged

@miniBill
Copy link
Collaborator Author

Ah, the squashed commit's message is. Wrong :(

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