mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml, semver: minor optimization of conditions (#18299)
This commit is contained in:
parent
0b71cef78a
commit
af05cfcbbc
@ -34,7 +34,7 @@ struct InvalidComparatorFormatError {
|
||||
}
|
||||
|
||||
fn (r Range) satisfies(ver Version) bool {
|
||||
return true in r.comparator_sets.map(it.satisfies(ver))
|
||||
return r.comparator_sets.any(it.satisfies(ver))
|
||||
}
|
||||
|
||||
fn (set ComparatorSet) satisfies(ver Version) bool {
|
||||
|
@ -592,16 +592,17 @@ fn (mut s Scanner) extract_number() !string {
|
||||
for s.pos < s.text.len {
|
||||
c = s.at()
|
||||
// Adjust scanner position to floating point numbers
|
||||
mut i, mut float_precision := 1, 0
|
||||
for c_ := u8(s.peek(i)); c_ != scanner.end_of_text && c_ != `\n`; c_ = u8(s.peek(i)) {
|
||||
if !c_.is_digit() && c_ != `.` && c_ != `,` {
|
||||
float_precision = 0
|
||||
break
|
||||
}
|
||||
if c_.is_digit() && c == `.` {
|
||||
mut float_precision := 0
|
||||
if c == `.` {
|
||||
mut i := 1
|
||||
for c_ := u8(s.peek(i)); c_ != scanner.end_of_text && c_ != `\n`; c_ = u8(s.peek(i)) {
|
||||
if !c_.is_digit() && c_ != `,` {
|
||||
float_precision = 0
|
||||
break
|
||||
}
|
||||
float_precision++
|
||||
i++
|
||||
}
|
||||
i++
|
||||
}
|
||||
s.pos += float_precision
|
||||
s.col += float_precision
|
||||
|
Loading…
Reference in New Issue
Block a user