diff options
author | Tom Scogland <scogland1@llnl.gov> | 2021-06-04 00:23:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-04 09:23:37 +0200 |
commit | b63a8b3e273bf6530658a81b2e43da36c1912c40 (patch) | |
tree | d577c8612f3d1dac30cfd7cf7e52e328279385b4 /var | |
parent | ea390198f4546c064dc7a470c4cfff4b28bfae95 (diff) | |
download | spack-b63a8b3e273bf6530658a81b2e43da36c1912c40.tar.gz spack-b63a8b3e273bf6530658a81b2e43da36c1912c40.tar.bz2 spack-b63a8b3e273bf6530658a81b2e43da36c1912c40.tar.xz spack-b63a8b3e273bf6530658a81b2e43da36c1912c40.zip |
Speed-up version parsing and comparison (#22973)
The VALID_VERSION regex didn't check that the version string was
completely valid, only that a prefix of it was. This version ensures
the entire string represents a valid version.
This makes a few related changes.
1. Make the SEGMENT_REGEX identify *which* arm it matches by what groups
are populated, including whether it's a string or int component or a
separator all at once.
2. Use the updated regex to parse the input once with a findall rather
than twice, once with findall and once with split, since the version
components and separators can be distinguished by their group status.
3. Rather than "convert to int, on exception stay string," if the int
group is set then convert to int, if not then construct an instance
of the VersionStrComponent class
4. VersionStrComponent now implements all of the special string
comparison logic as part of its __lt__ and __eq__ methods to deal
with infinity versions and also overloads comparison with integers.
5. Version now uses direct tuple comparison since it has no per-element
special logic outside the VersionStrComponent class.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
Diffstat (limited to 'var')
0 files changed, 0 insertions, 0 deletions