Skip to content

Conversation

@fwininger
Copy link
Owner

No description provided.

jinxka and others added 30 commits June 20, 2018 16:56
Signed-off-by: jinxka <benjamin.balanger@epitech.eu>
New methods to get major.minor.patch
Add benchmark for comparing versions
Fix SoftwareVersion::Version#sv
Signed-off-by: Florian Wininger <fw.centrale@gmail.com>
Signed-off-by: Florian Wininger <fw.centrale@gmail.com>
Signed-off-by: Florian Wininger <fw.centrale@gmail.com>
Signed-off-by: Florian Wininger <fw.centrale@gmail.com>
1.1-1-3 < 1.1-2 was false
Rather than splitting strings, the new comparison model uses a
left-to-right version parser to extract the semantic of the versions,
and compares the resulting tokens lexicographically. That way, we have
v1.0.1 = 1.0p1 without requiring preprocessing from the caller.

While more verbose, the new parser should make it easy to add special
cases for magic words like pre-versions.

Versions can now be compared to any stringizable objects for
convenience.

Regarding performance, this current implementation is about 5 times
slower than the previous one, though this could be improved by
profiling.

The new implementation does not have special cases for distributions or
architectures, which generate a huge difference when sorting
heterogeneous versions, like with RPM.
Rather than writing `SoftwareVersion::Version.new('1.0')`, users will be
able to write `SoftwareVersion('1.0')` instead.
This removes the legacy parse_raw_version to use the new parser instead.

This is a breaking change, as the semantics change slightly. The
`KB.16.10.0012` is now read as major = 16, minor = 10 and patch = 12.

Methods #version, #revision, #release and #arch have be deleted.
String#chunk is actually pretty slow, and makes us call #join
afterwards. Implementing our own loop with #each_char is more verbose,
but makes the benchmark 20% faster.
The overhead caused by the Struct slows down the benchmark by about 10%.
Arrays are a bit less readable, but the code remains clear enough.
@fwininger fwininger force-pushed the add_gh branch 3 times, most recently from 7bc3933 to abde6ef Compare October 31, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants