Fork me on GitHub
Adam Kalisz12:04:28

No worry. We use the specific UUIDv4 regex at OrgPad for all the parsing. The more general one will definitely work too. Btw. this ties into my work on speeding up random-uuid in CLJS: The pseudo-random version is about 2x faster and can be applied immediately. The upgraded version, that tries to use the crypto API needs some work on detection.


Sorry I took so long to get to this. I have 2 comments to make on the regex: 1. Yes, the individual patterns should have been [0-9a-fZ-F]. That was a mistake. 2. I actually started with the shorter form:

(That's a copy-paste from my first version, which includes the a-z mistake) The reason for fully expanding it was a long discussion with @mfikes on February 3rd. Mike identified that the shorter form of regex was significantly slower than when fully expanded. We benchmarked various approaches, and eventually came up with the fully expanded version.


So, the correct one would be:

Yes, it's long and messy, but it's hidden inside the namespace where few people look, and it's significantly faster

Adam Kalisz08:04:53

Yes, about 2x in my testing. We can perhaps reformat it with (re-pattern (str ...)) as suggested in Jira and DM. There are still some questions about how that behaves on namespace load and with the compiler.


This is where Mike's advice comes in. He's better at this than I am, but he pointed out that the Google Closure compiler (which is essentially a block box from the ClojureScript perspective) is unable to identify that the re-pattern/`str` code is unneeded when the function is not used. However, the literal syntax for the regex is identified and works cleanly.

👍 1

I created for the regex update, and included some more uuid tests

👍 1