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

#24 rename package to roave/backward-compatibility-check #50

Merged
merged 21 commits into from
Apr 27, 2018
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
96586a9
#24 renamed package to `roave/backward-compatibility-check`
Ocramius Apr 27, 2018
e119e62
#24 renamed `Roave\ApiCompare\Comparator\BackwardsCompatibility` to `…
Ocramius Apr 27, 2018
62eeb33
#24 renamed all `compare()` methods on all BC break detectors to just…
Ocramius Apr 27, 2018
4ead51c
#24 renamed `Changes::new()` to `Changes::empty()`
Ocramius Apr 27, 2018
2bca1ac
#24 minor performance optimisation: if `Changes#mergeWith()` is merge…
Ocramius Apr 27, 2018
ecd9ed9
#24 removed `Changes#withAddedChange()`, as `mergeWith` is the prefer…
Ocramius Apr 27, 2018
b416323
#24 renamed `Changes::fromArray()` in favour of `Changes::fromList()`…
Ocramius Apr 27, 2018
d59ee07
#24 avoid greedy usage of `array_merge()` where a splat operator woul…
Ocramius Apr 27, 2018
4c4ba88
#24 performance/memory optimisation: avoid trashing memory with `Chan…
Ocramius Apr 27, 2018
692de1d
#24 corrected `exclude-pattern` entries in the phpcs config (forgot a…
Ocramius Apr 27, 2018
9c0053b
#24 verifying that `Changes#mergeWith()` avoids copy-on-write when an…
Ocramius Apr 27, 2018
ef30d0b
#24 changed command name and description
Ocramius Apr 27, 2018
fb19272
#24 renamed command class to match command name
Ocramius Apr 27, 2018
9e897d1
#24 using `1` as exit code for failed checks - exit code `2` is reser…
Ocramius Apr 27, 2018
ba589c2
#24 renamed package from `Roave\ApiCompare` to `Roave\BackwardCompati…
Ocramius Apr 27, 2018
c7f98d8
#24 added binary to composer binary paths
Ocramius Apr 27, 2018
4f95a2c
#24 added BC verification to the travis build
Ocramius Apr 27, 2018
2dcfd7f
#24 added a success/failure message at the end of the execution of th…
Ocramius Apr 27, 2018
e539096
#24 improved CLI command documentation by dcumenting all options
Ocramius Apr 27, 2018
2c8fe42
#24 moved most docs to the CLI command itself: `--help` is our friend!
Ocramius Apr 27, 2018
ea02a5d
#24 using exit code `3` instead of `1` for when BC breaks are detected
Ocramius Apr 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#24 performance/memory optimisation: avoid trashing memory with `Chan…
…ges::empty()`
  • Loading branch information
Ocramius committed Apr 27, 2018
commit 4c4ba887d03f478639af927b743608176a5fd076
16 changes: 13 additions & 3 deletions src/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@
final class Changes implements IteratorAggregate, Countable
{
/** @var Change[] */
private $changes = [];
private $changes;

private function __construct()
{
}

public static function empty() : self
{
return new self();
static $empty;

if ($empty) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I found (via Kcachegrind) that this was really trashing memory and CPU on this side (together with fromArray() and mergeWith())

return $empty;
}

$empty = new self();

$empty->changes = [];

return $empty;
}

public static function fromList(Change ...$changes) : self
Expand All @@ -36,7 +46,7 @@ public static function fromList(Change ...$changes) : self

public function mergeWith(self $other) : self
{
if (empty($other->changes)) {
if (! $other->changes) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Looked useless at first, but saves us from loads of instantiations

return $this;
}

Expand Down