Skip to content

Conversation

@thiemowmde
Copy link
Contributor

@thiemowmde thiemowmde commented Feb 7, 2017

This patch does have two effects:

  • It merges duplicate loops that looped the exact same arrays twice.
  • This allows to avoid a few duplicate condition checks, e.g. duplicate is_string.

This is a direct follow up for #205.

Bug: T157959

@thiemowmde
Copy link
Contributor Author

@mariushoch @JeroenDeDauw I suggest to merge at least this (and possibly #207) before tagging the new release (which is already prepared via #209).

@thiemowmde
Copy link
Contributor Author

Benchmarked locally. Performance gain is a bit more than 3%.

@JeroenDeDauw
Copy link
Contributor

3% when just calling the deserialization code? What about in any real world use case where the data needs to be read from somewhere? I imagine it is no longer significant then

@thiemowmde
Copy link
Contributor Author

Even if it's only 1% in a real world scenario, 1% equals 20 minutes, according to https://phabricator.wikimedia.org/T157013#2993060. Under these circumstances I don't think it's worth arguing what the value of duplicate code is.

@thiemowmde thiemowmde added this to the 2.3.0 milestone Feb 13, 2017
@thiemowmde thiemowmde mentioned this pull request Feb 13, 2017
foreach ( $serialization as $key => $statementArray ) {
if ( is_string( $key ) ) {
if ( !is_array( $statementArray ) ) {
throw new DeserializationException( 'The statements per property should be an array' );
Copy link

Choose a reason for hiding this comment

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

Would be nice to mention key in the message

foreach ( $serialization as $key => $snakArray ) {
if ( is_string( $key ) ) {
if ( !is_array( $snakArray ) ) {
throw new DeserializationException( 'The snaks per property should be an array' );
Copy link

Choose a reason for hiding this comment

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

Would be nice to mention key here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both cases are old exception messages, and I did not wanted to change them, but I can.

@JeroenDeDauw
Copy link
Contributor

Well is it even 1%? If it's 3% just when executing the PHP code I expect it to be way less than 1% when holding i/o into account.

@manicki
Copy link
Member

manicki commented Feb 14, 2017

+1
I am not convinced by the impact of this but I not opposing.

@manicki manicki merged commit 7d7b0ce into master Feb 14, 2017
@manicki manicki deleted the arrayLoops branch February 14, 2017 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants