Skip to content

Commit 1ece3b9

Browse files
committed
- optimization: use pre-increment
1 parent 352a00e commit 1ece3b9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ULID.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private function __construct(int $timestamps, int $count)
6666
throw new ArgumentCountError('count must be greater then 0', 400);
6767
}
6868
$this->randomize(false);
69-
for ($i = 0; $i < $count; $i++) {
69+
for ($i = 0; $i < $count; ++$i) {
7070
$this->timestamps[$i] = $timestamps;
7171
}
7272
}
@@ -97,7 +97,7 @@ public static function fromULID(string $ulid): self
9797
}
9898
$timestamp = 0;
9999
$chars = substr($ulid, 0, 10);
100-
for ($i = 0; $i < 10; $i++) {
100+
for ($i = 0; $i < 10; ++$i) {
101101
$timestamp = $timestamp * 32 + strpos(static::ENCODING, $chars[$i]);
102102
}
103103
return new static ($timestamp, 1);
@@ -232,7 +232,7 @@ private function generateUuidParts(int $milliseconds): int
232232
$sameTimestamp = $lastTime === $milliseconds;
233233
$lastTime = $milliseconds;
234234
if ($sameTimestamp) {
235-
$this->randomness[2]++;
235+
++$this->randomness[2];
236236
} else {
237237
$this->randomize(false);
238238
}
@@ -271,7 +271,7 @@ private function randomize(bool $list): void
271271
{
272272
if ($list) {
273273
$this->randomness = [];
274-
for ($i = 0; $i < 16; $i++) {
274+
for ($i = 0; $i < 16; ++$i) {
275275
$this->randomness[] = mt_rand(0, 31);
276276
}
277277
} else {

0 commit comments

Comments
 (0)