Let Ziran widen values without explicit casts
`ziran check --lint` found six casts that only widen a whole assigned value (u8 to s32 or u32, float32 to float64). They are removed; the hex digit arithmetic still happens on the byte before it widens. The generated C of every KSS entry is identical before and after.
This commit is contained in:
1 parent
436959c44f
commit
d416dde5d6
4 files changed
+6
-6
No files matched your search
@@ -357,7 +357,7 @@ KssFormatScanNext :: (source: string, scan: KssFormatScan, end: s32) -> KssForma
|
||||
scan.pos = at + 1
|
||||
if scan.mode == 0 {
|
||||
if byte == #char "\"" || byte == #char "'" {
|
||||
scan.mode = cast(s32)byte
|
||||
scan.mode = byte
|
||||
} else if byte == #char "/" && next == #char "*" {
|
||||
scan.mode = 42
|
||||
scan.pos = at + 2
|
||||
|
||||
@@ -935,7 +935,7 @@ KssResolveCSSValue :: (p: KssParser, property: string, source: string) -> KssCSS
|
||||
result.material = p.tokens[index].material
|
||||
} else {
|
||||
result.kind = cast(s32)KssCSSNumber
|
||||
result.number = cast(float64)p.tokens[index].number
|
||||
result.number = p.tokens[index].number
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
+3
-3
@@ -359,11 +359,11 @@ KssReadHexColor :: (c: KssCursor) -> KssColorResult {
|
||||
byte: u8 = c.source[c.pos]
|
||||
digit: u32 = 0
|
||||
if byte >= #char "0" && byte <= #char "9" {
|
||||
digit = cast(u32)(byte - 48)
|
||||
digit = byte - 48
|
||||
} else if byte >= #char "a" && byte <= #char "f" {
|
||||
digit = cast(u32)(byte - 87)
|
||||
digit = byte - 87
|
||||
} else {
|
||||
digit = cast(u32)(byte - 55)
|
||||
digit = byte - 55
|
||||
}
|
||||
value = (value << cast(u32)4) | digit
|
||||
digits = digits + 1
|
||||
|
||||
@@ -537,7 +537,7 @@ KssSelectorPartMode :: (c: KssCursor, sequence: bool, relative: bool) -> KssSele
|
||||
if initial == 0 && !relative {
|
||||
return result
|
||||
}
|
||||
result.combinator = cast(s32)byte
|
||||
result.combinator = byte
|
||||
skipped = KssSelectorSpace(KssAdvance(c, 1))
|
||||
c = skipped.parser
|
||||
result.parser = c
|
||||
|
||||
Reference in new issue
Block a user