aboutsummaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-08 02:55:08 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-08 02:55:08 +0200
commit28f20005d69fe35282501861f088bae655a39acd (patch)
tree59ead141f2358627a558b4d734d6c304eee6a577 /src/types
parentdef6f3e5c28974063b650db194a0c055d4dea685 (diff)
downloadchawan-28f20005d69fe35282501861f088bae655a39acd.tar.gz
Remove unnecessary std/math imports
Diffstat (limited to 'src/types')
-rw-r--r--src/types/url.nim7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/types/url.nim b/src/types/url.nim
index 93a63617..10394020 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -1,6 +1,5 @@
# See https://url.spec.whatwg.org/#url-parsing.
import std/algorithm
-import std/math
import std/options
import std/strutils
import std/tables
@@ -209,13 +208,13 @@ func parseIpv4(input: string): Option[uint32] =
if i != high(parts):
return none(uint32)
numbers.add(num)
- if numbers[^1] >= 256^(5-numbers.len):
+ if numbers[^1] >= 1 shl ((5 - numbers.len) * 8):
return none(uint32)
var ipv4 = uint32(numbers[^1])
discard numbers.pop()
for i in 0..numbers.high:
let n = uint32(numbers[i])
- ipv4 += n * (256u32 ^ (3 - i))
+ ipv4 += n * (1u32 shl ((3 - i) * 8))
return ipv4.some
const ForbiddenHostChars = {
@@ -836,7 +835,7 @@ func serializeip(ipv4: uint32): string =
result = $(n mod 256) & result
if i != 4:
result = '.' & result
- n = n.floorDiv 256u32
+ n = n div 256
assert n == 0
func findZeroSeq(ipv6: array[8, uint16]): int =