From 0a198d3d11cdff483919c5632e2261687587ed9d Mon Sep 17 00:00:00 2001 From: Iain Mckay Date: Thu, 9 Mar 2017 09:01:12 +0100 Subject: [PATCH] Improves memory usage when generating large quantities of UUID's --- src/UuidFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UuidFactory.php b/src/UuidFactory.php index e0f2aaf..77d2383 100644 --- a/src/UuidFactory.php +++ b/src/UuidFactory.php @@ -281,8 +281,8 @@ class UuidFactory implements UuidFactoryInterface $fields = array( 'time_low' => substr($hash, 0, 8), 'time_mid' => substr($hash, 8, 4), - 'time_hi_and_version' => sprintf('%04x', $timeHi), - 'clock_seq_hi_and_reserved' => sprintf('%02x', $clockSeqHi), + 'time_hi_and_version' => str_pad(dechex($timeHi), 4, '0', STR_PAD_LEFT), + 'clock_seq_hi_and_reserved' => str_pad(dechex($clockSeqHi), 2, '0', STR_PAD_LEFT), 'clock_seq_low' => substr($hash, 18, 2), 'node' => substr($hash, 20, 12), );