Skip to content

Commit

Permalink
Remove an over-optimisation that helps occasionally by saving a furth…
Browse files Browse the repository at this point in the history
…er iteration over the itemlist when there's a perfect fit, but causes additional computations otherwise. Overall effect seems to be basically zero, but removing it aids understanding
  • Loading branch information
dvdoug committed Mar 9, 2020
1 parent e948053 commit 4b02cdc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/VolumePacker.php
Expand Up @@ -205,7 +205,7 @@ protected function packLayer(int $startDepth, int $widthLeft, int $lengthLeft, i
while ($this->items->count() > 2 && static::isSameDimensions($itemToPack, $this->items->top())) {
$this->skippedItems[] = $this->items->extract();
}
} elseif ($x > 0 && $lengthLeft >= min($itemToPack->getWidth(), $itemToPack->getLength(), $itemToPack->getDepth())) {
} elseif ($x > 0) {
$this->logger->debug('No more fit in width wise, resetting for new row');
$widthLeft += $rowWidth;
$lengthLeft -= $rowLength;
Expand Down
4 changes: 2 additions & 2 deletions tests/data/expected.csv
Expand Up @@ -868,7 +868,7 @@
3223ff53874ff3768881db6e163c96a3,2,99856,31.5,1,0,19.1
323d3a61ac8f60761edc56c34b339a1d,1,0,40.8,1,0,40.8
3242e661790ad530e5a8419a5c7c0b5b,1,0,22.8,1,0,22.8
3247e39c4bfd94e9f525f7ef5c179317,2,403225,70.1,2,5929,29.2
3247e39c4bfd94e9f525f7ef5c179317,2,403225,70.1,1,0,42.4
326b6af0e5d3ac4f72622ce744ee4b27,1,0,32.4,1,0,32.4
3276e0aa9afede0f2e5b0d5e3dcf7426,2,14884,23.9,1,0,7.2
328f28aadcd871aa3ade0646fda55b85,1,0,25.2,1,0,25.2
Expand Down Expand Up @@ -1785,7 +1785,7 @@
66cfc755b3bf57a31443b880a13b8329,1,0,19.9,1,0,19.9
66d19a0cf23fd8bdc01c8ce6331b005e,1,0,26.4,1,0,26.4
66dc2656db4413ae3e09c518ed7bb556,1,0,23.6,1,0,23.6
66dc2e0b086507a10167fbafabee6ac2,3,12923532.7,36.2,3,4554.9,23.6
66dc2e0b086507a10167fbafabee6ac2,3,12923532.7,36.2,3,17254.9,23.6
66e7fc5f91b1a25a68ecbe3db9b7742e,1,0,82.7,1,0,82.7
66ff7bfe4da0b72b1fe35f5e211915f2,1,0,19.7,1,0,19.7
673678add1d458f12ec22ab7030a368b,1,0,18.5,1,0,18.5
Expand Down

0 comments on commit 4b02cdc

Please sign in to comment.