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 {
|
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 {
|
fn (set ComparatorSet) satisfies(ver Version) bool {
|
||||||
|
@ -592,17 +592,18 @@ fn (mut s Scanner) extract_number() !string {
|
|||||||
for s.pos < s.text.len {
|
for s.pos < s.text.len {
|
||||||
c = s.at()
|
c = s.at()
|
||||||
// Adjust scanner position to floating point numbers
|
// Adjust scanner position to floating point numbers
|
||||||
mut i, mut float_precision := 1, 0
|
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)) {
|
for c_ := u8(s.peek(i)); c_ != scanner.end_of_text && c_ != `\n`; c_ = u8(s.peek(i)) {
|
||||||
if !c_.is_digit() && c_ != `.` && c_ != `,` {
|
if !c_.is_digit() && c_ != `,` {
|
||||||
float_precision = 0
|
float_precision = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if c_.is_digit() && c == `.` {
|
|
||||||
float_precision++
|
float_precision++
|
||||||
}
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
}
|
||||||
s.pos += float_precision
|
s.pos += float_precision
|
||||||
s.col += float_precision
|
s.col += float_precision
|
||||||
// Handle signed exponent notation. I.e.: 3e2, 3E2, 3e-2, 3E+2, 3e0, 3.1e2, 3.1E2, -1E-1
|
// Handle signed exponent notation. I.e.: 3e2, 3E2, 3e-2, 3E+2, 3e0, 3.1e2, 3.1E2, -1E-1
|
||||||
|
Loading…
Reference in New Issue
Block a user