diff options
author | bptato <nincsnevem662@gmail.com> | 2023-11-20 17:20:41 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-11-20 17:20:41 +0100 |
commit | 342a1a7f787fc260448842ee312cf29825f96ba6 (patch) | |
tree | e4e1d28e424e60da8b2618195c40442b79bd2ba8 /src/css | |
parent | d20fc30e10aeecfb2ede7adc4547b9ae394565b9 (diff) | |
download | chawan-342a1a7f787fc260448842ee312cf29825f96ba6.tar.gz |
twtstr: remove tolower, isWhitespace
* tolower: strutils toLowerAscii is good enough for the cases where we need it. Also, it's easy to confuse with unicode toLower and vice versa. * isWhitespace: in AsciiWhitespace is more idiomatic. Also has a naming collision with unicode toLower.
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/cssparser.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/css/cssparser.nim b/src/css/cssparser.nim index ea337ab1..a8081ecc 100644 --- a/src/css/cssparser.nim +++ b/src/css/cssparser.nim @@ -248,7 +248,7 @@ proc consumeEscape(state: var CSSTokenizerState): string = num *= 0x10 num += hexValue(c) inc i - if state.peek().isWhitespace(): + if state.peek() in AsciiWhitespace: discard state.consume() if num == 0 or num > 0x10FFFF or num in 0xD800..0xDFFF: return $Rune(0xFFFD) @@ -347,7 +347,7 @@ const NonPrintable = {char(0x00)..char(0x08), char(0x0B), char(0x0E)..char(0x1F) proc consumeURL(state: var CSSTokenizerState): CSSToken = result = CSSToken(tokenType: CSS_URL_TOKEN) - while state.has() and state.peek().isWhitespace(): + while state.has() and state.peek() in AsciiWhitespace: discard state.consume() while state.has(): @@ -359,7 +359,7 @@ proc consumeURL(state: var CSSTokenizerState): CSSToken = state.consumeBadURL() return CSSToken(tokenType: CSS_BAD_URL_TOKEN) of AsciiWhitespace: - while state.has() and state.peek().isWhitespace(): + while state.has() and state.peek() in AsciiWhitespace: discard state.consume() if not state.has(): return result @@ -382,7 +382,8 @@ proc consumeIdentLikeToken(state: var CSSTokenizerState): CSSToken = let s = state.consumeIdentSequence() if s.equalsIgnoreCase("url") and state.has() and state.peek() == '(': discard state.consume() - while state.has(1) and state.peek().isWhitespace() and state.peek(1).isWhitespace(): + while state.has(1) and state.peek() in AsciiWhitespace and + state.peek(1) in AsciiWhitespace: discard state.consume() if state.has() and state.peek() in {'"', '\''} or state.has(1) and state.peek() in {'"', '\''} + AsciiWhitespace and state.peek(1) in {'"', '\''}: @@ -413,7 +414,7 @@ proc consumeToken(state: var CSSTokenizerState): CSSToken = let c = state.consume() case c of AsciiWhitespace: - while state.has() and state.peek().isWhitespace(): + while state.has() and state.peek() in AsciiWhitespace: discard state.consume() return CSSToken(tokenType: CSS_WHITESPACE_TOKEN) of '"', '\'': |