Commit Graph

190 Commits

Author SHA1 Message Date
Ben Ramsey dced71b87a Use str_pad() and dechex() instead of sprint()
This is a micro-optimization that improves memory usage when generating
large quantities of UUIDs. See #159 and #160.
2017-09-22 14:27:30 -05:00
Ben Ramsey 5c38d41ccb Use sprintf() to prefix zeros on the returned node hex string 2017-09-22 13:03:41 -05:00
Ben Ramsey 1ec0826a40 Set the multicast bit for random nodes, according to RFC 4122, §4.5
Borrows the idea from cf1c981414 to
properly set the multicast bit to the "least significant bit of the
first octet of the node ID."

When merged, this will close #171 and #170
2017-09-22 12:54:15 -05:00
Ben Ramsey aab08bb08a Use random_bytes() to generate a random node 2017-09-22 12:26:34 -05:00
Davis Peixoto 0915c7bdc2 173 - Expose UUID versions - Alternative 1
https://github.com/ramsey/uuid/issues/173

Creating constants on Uuid object, so they can be used as
- UUID::UUID_TYPE_TIME
- UUID::UUID_TYPE_RANDOM

# Alternative 1
Create constants on Uuid class

Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com>
2017-08-02 08:55:26 -03:00
Davis Peixoto 3d1db97b4d 173 - Expose UUID versions - Alternative 1
https://github.com/ramsey/uuid/issues/173

Creating constants on Uuid object, so they can be used as
- Uuid::UUID_TYPE_TIME
- Uuid::UUID_TYPE_RANDOM

Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com>
2017-08-01 15:40:21 -03:00
Martin Hujer 4eefce356d Optimize UUID string decoding
I realized, that 30% of the request time in our app is spent by
hydrating the uuid (We are using Doctrine and in this specific request
I was accidentally hydrating few thousands entities). Luckily, I
remembered the #160 and tried to do similar optimization for uuid
decoding. It resulted in 10-20% performance improvement.
2017-03-26 19:02:20 +02:00
Massimiliano Arione a2647abc14 add a specific exception for invalid UUID string 2017-03-11 10:52:53 +01:00
Iain Mckay 0a198d3d11 Improves memory usage when generating large quantities of UUID's 2017-03-09 09:01:12 +01:00
Jessica Mauerhan e80e3d5828 Convert string to lowercase. Fixes GH Issue #131 2016-09-30 16:01:45 -04:00
Ben Ramsey 2e674a1713 Merge pull request #118 from barryvdh/optimized
Codec to store UUID in an optimized way for InnoDB
2016-08-02 13:53:14 -04:00
Anton Vasetskiy 879fe3cfe2 Fix RandomNodeProvider: change the max value in mt_rand() call to prevent invalid node generation 2016-07-28 16:44:26 +03:00
Ben Ramsey e865a0e2ff Merge branch '107_cache_system_node_provider' of https://github.com/MLoureiro/uuid into MLoureiro-107_cache_system_node_provider 2016-06-24 23:58:19 +02:00
Marcos ab81ad278a Remove duplicated call to str_replace() 2016-06-24 20:46:51 +02:00
Marcos 5dbd993b4b Execute system call only once even if the node is not found 2016-06-23 21:03:07 +02:00
Barry vd. Heuvel ca0cc642aa Add OrderedTimeCodec + test 2016-04-27 21:38:55 +02:00
Alex Farcas c7cf416f23 Implemented timestamp first and timestamp last comb generators 2016-03-22 22:04:05 +02:00
Alex Farcas ad6f0747bd Implemented timestamp first and timestamp last comb generators 2016-03-18 16:49:19 +02:00
Ben Ramsey 35247faecf Drop the use of OpenSSL as a fallback and use paragonie/random_compat
Fixes issue #80 for the 3.x series
2016-03-15 11:45:18 -05:00
Ben Ramsey e4e38b4059 Add random generator for the PECL libsodium extension 2016-02-13 20:29:32 -06:00
frankdejonge 91d0c6da31 Fixes #91: Made Uuid's serializable. 2015-10-25 22:15:32 +01:00
Emir Beganovic 264a6ceca3 Boolean should be compared strictly 2015-10-07 02:28:06 +02:00
Emir Beganovic 94e39e8202 Add new line after last use 2015-10-05 10:21:32 +02:00
Emir Beganovic fb1cd7a944 Cleanup: Update and add missing docblocks, remove unused imports
Just a bit of house keeping for the sake of code cleanliness.
2015-10-05 10:18:21 +02:00
Ben Ramsey 15db91b8f6 Fix minor issues highlighted by Scrutinizer 2015-09-28 12:19:57 -05:00
Ben Ramsey 4e548705c0 Point to Ramsey\Uuid\UuidInterface::getFieldsHex instead 2015-09-27 18:59:32 -05:00
Ben Ramsey e6f97dc8ab Add docblocks for classes and interfaces in top-level Ramsey\Uuid namespace 2015-09-27 18:58:50 -05:00
Ben Ramsey d975f0f143 Add docblocks for classes and interfaces in Ramsey\Uuid\Provider namespace 2015-09-27 13:02:30 -05:00
Ben Ramsey 5bf7f5064c Add docblocks for classes and interfaces in Ramsey\Uuid\Generator namespace 2015-09-26 19:06:21 -05:00
Ben Ramsey dc26d4addb Add docblocks for classes and interfaces in Ramsey\Uuid\Converter namespace 2015-09-26 18:06:02 -05:00
Ben Ramsey 77a34348d5 Add docblocks for classes and interface in Ramsey\Uuid\Codec namespace 2015-09-03 23:28:07 -04:00
Ben Ramsey 67fe80dc1b Add docblocks for classes and interface in Ramsey\Uuid\Builder namespace 2015-09-03 23:00:55 -04:00
Ben Ramsey e99347f70d Merge pull request #77 from aztech-forks/master
Improve GUID support
2015-08-28 09:36:45 -05:00
Aztech 4c35be716a Remove message assertion -- cannot pass in both 32 and 64 bits envs 2015-08-14 23:26:15 +02:00
Aztech 8c699ecfec Fix exception message assertion in tests 2015-08-14 23:10:23 +02:00
Aztech 896cd9c4e2 Use GUID codec in all cases as it is now endianness independant 2015-08-14 22:43:58 +02:00
Aztech 958468d95b Detect host endianness when building codec 2015-08-14 22:24:16 +02:00
Aztech d3535feb50 Use host dependant endianness in GUID string codec 2015-08-14 21:57:59 +02:00
Ben Ramsey cf1776ebd6 Fix incompatible return type declaration issue
Scrutinizer turned up this issue, since the declared return type in
`UuidBuilderInterface` was of `Uuid` and we weren't properly importing
`\Ramsey\Uuid\Uuid` in a `use` statement.
2015-08-13 11:00:41 -05:00
Thibaud Fabre 89d91a97eb Remove unnecessary conversions in BigNumberConverter
Using the baseConvert method from BigNumber uses two consecutive convert operations:
  - convertToBase10
  - convertFromBase10

In BigNumberConverters context, we can directly call each specific method to avoid
the conversion overhead.
2015-08-13 17:44:40 +02:00
Scrutinizer Auto-Fixer f59b447603 Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
2015-08-13 15:32:44 +00:00
Aztech bbce46dabe Add option to enable PeclUuidTimeGenerator via FeatureSet 2015-07-28 22:20:04 +02:00
Aztech 0cd74639cf Enable use of custom TimeGenerator implementations
- Removes now unnecessary `timeConverter` and `timeProvider`
  properties, setters, and getters in both FeatureSet and
  UuidFactory as those are now exclusively used by the default
  TimeGenerator
- Adds a `setTimeGenerator` method on UuidFactory to override the
  default time generator
2015-07-28 22:16:29 +02:00
Ben Ramsey 83367cef97 Use a medium strength generator for ircmaxell/random-lib
As discussed in https://github.com/ramsey/uuid/issues/56
2015-07-28 11:29:43 -05:00
Ben Ramsey e81568ea4f Fix parse error caused by double "new" keyword 2015-07-28 11:28:07 -05:00
Ben Ramsey a95140c25c Remove PeclUuidFactory in favor of the new PeclUuid*Generator 2015-07-28 11:25:07 -05:00
Ben Ramsey d88a941b8c Fix errant docblock comment asterisk removal 2015-07-27 11:14:42 -05:00
Aztech e2047199cd Remove redundant method call 2015-07-27 11:14:20 -05:00
Aztech ec3f5bbdc8 CS fix 2015-07-27 11:14:20 -05:00
Aztech 8974c76bf6 Refactor TimeGeneratorInterface
- Remove UuidFactory from signature
- Remove setters on UuidFactory to prevent inconsistencies (a new feature set and factory should be used instead)
- Update tests to reflect those changes
2015-07-27 11:14:20 -05:00