-
Notifications
You must be signed in to change notification settings - Fork 2
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
Change ValueObject initializer #64
Draft
pjaspers
wants to merge
9
commits into
master
Choose a base branch
from
pj/value-object-speedup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mestachs I'd be curious to know if this is performing better on Linux than on Mac The other thing is, I think I might have made loading from yaml slower, so that will be annoying as well to compare (since both this spec suite, and the 'data-tests' in orbf2 use it as well) But for what it's worth on travis it seems to behaving similarly to master (7.74s vs 7.75s) |
Merged
@pjaspers rebase this against latest |
pjaspers
force-pushed
the
pj/value-object-speedup
branch
from
March 3, 2022 16:35
0a1a6ba
to
371b61f
Compare
This is mostly to do with the keyword arguments being more strict. Where we used to be able to just throw a hash to a method, we now need to explicitly tell ruby to treat the hash as keyword arguments. This fixes these calls. We have a couple of places in our used gems where this still pops up: /Users/pjaspers/development/blsq/orbf-rules_engine/vendor/ruby/2.7.0/gems/dentaku-3.3.4/lib/dentaku/exceptions.rb:95: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /Users/pjaspers/development/blsq/orbf-rules_engine/vendor/ruby/2.7.0/gems/dentaku-3.3.4/lib/dentaku/exceptions.rb:78: warning: The called method `initialize' is defined here And /Users/pjaspers/development/blsq/orbf-rules_engine/vendor/ruby/2.7.0/gems/dhis2-2.3.8/lib/dhis2/collection_wrapper.rb:12: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /Users/pjaspers/development/blsq/orbf-rules_engine/vendor/ruby/2.7.0/gems/dhis2-2.3.8/lib/dhis2/api/analytic.rb:7: warning: The called method `list' is defined here
Explicitly install newer bundler (travis defaults to 1.x bundler), on ruby 2.7 this step isn't needed, but the other ones do need it. Since the bundler will be cached after the first install let's keep it like this.
Instead of looping and settings isntance variables, this will create the model once (with the right attrs) and then do as little as possible to set them. In order for this to work, I've had to hunt down each `new` and replace it with a `with`.
pjaspers
force-pushed
the
pj/value-object-speedup
branch
from
March 3, 2022 16:54
1d8cff3
to
7fb0972
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So while testing support for multiple rubies: see #63 (which is also included in this one) we ran into some deprecations in ruby 2.7, these had the following characteritic:
The
Hi.with
is fine, that's just a hash, but when we use theHiAgain
class with a keyword initializer, ruby will complain that we're using the last arguments as keyword arguments and that will break in ruby 3. (We're passing keyword args to a hash param)The obvious solution would be to
**
double splat, but that comes at quite a performance cost.So this takes a different approach, by copying/stealing some code from
Sequel
to have our ValueObject be configured with thefields
once, and then setting the values to one hash in instance variable.The good news is that it does shave off some allocations, the bad news is that I don't see any real performance benefit. So keeping this in draft for now.