inline tiny func on httpcore (#15480)
This commit is contained in:
parent
f25ca0d304
commit
1e28cea0d1
1 changed files with 14 additions and 16 deletions
|
|
@ -134,10 +134,10 @@ func newHttpHeaders*(keyValuePairs:
|
||||||
result.table[key] = @[pair.val]
|
result.table[key] = @[pair.val]
|
||||||
|
|
||||||
|
|
||||||
func `$`*(headers: HttpHeaders): string =
|
func `$`*(headers: HttpHeaders): string {.inline.} =
|
||||||
return $headers.table
|
$headers.table
|
||||||
|
|
||||||
proc clear*(headers: HttpHeaders) =
|
proc clear*(headers: HttpHeaders) {.inline.} =
|
||||||
headers.table.clear()
|
headers.table.clear()
|
||||||
|
|
||||||
func `[]`*(headers: HttpHeaders, key: string): HttpHeaderValues =
|
func `[]`*(headers: HttpHeaders, key: string): HttpHeaderValues =
|
||||||
|
|
@ -206,7 +206,7 @@ func getOrDefault*(headers: HttpHeaders, key: string,
|
||||||
else:
|
else:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
func len*(headers: HttpHeaders): int = return headers.table.len
|
func len*(headers: HttpHeaders): int {.inline.} = headers.table.len
|
||||||
|
|
||||||
func parseList(line: string, list: var seq[string], start: int): int =
|
func parseList(line: string, list: var seq[string], start: int): int =
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
@ -323,21 +323,21 @@ proc `==`*(rawCode: string, code: HttpCode): bool
|
||||||
## string form of itself.
|
## string form of itself.
|
||||||
return cmpIgnoreCase(rawCode, $code) == 0
|
return cmpIgnoreCase(rawCode, $code) == 0
|
||||||
|
|
||||||
func is2xx*(code: HttpCode): bool =
|
func is2xx*(code: HttpCode): bool {.inline.} =
|
||||||
## Determines whether ``code`` is a 2xx HTTP status code.
|
## Determines whether ``code`` is a 2xx HTTP status code.
|
||||||
return code.int in {200 .. 299}
|
code.int in {200 .. 299}
|
||||||
|
|
||||||
func is3xx*(code: HttpCode): bool =
|
func is3xx*(code: HttpCode): bool {.inline.} =
|
||||||
## Determines whether ``code`` is a 3xx HTTP status code.
|
## Determines whether ``code`` is a 3xx HTTP status code.
|
||||||
return code.int in {300 .. 399}
|
code.int in {300 .. 399}
|
||||||
|
|
||||||
func is4xx*(code: HttpCode): bool =
|
func is4xx*(code: HttpCode): bool {.inline.} =
|
||||||
## Determines whether ``code`` is a 4xx HTTP status code.
|
## Determines whether ``code`` is a 4xx HTTP status code.
|
||||||
return code.int in {400 .. 499}
|
code.int in {400 .. 499}
|
||||||
|
|
||||||
func is5xx*(code: HttpCode): bool =
|
func is5xx*(code: HttpCode): bool {.inline.} =
|
||||||
## Determines whether ``code`` is a 5xx HTTP status code.
|
## Determines whether ``code`` is a 5xx HTTP status code.
|
||||||
return code.int in {500 .. 599}
|
code.int in {500 .. 599}
|
||||||
|
|
||||||
func `$`*(httpMethod: HttpMethod): string =
|
func `$`*(httpMethod: HttpMethod): string =
|
||||||
return (system.`$`(httpMethod))[4 .. ^1].toUpperAscii()
|
return (system.`$`(httpMethod))[4 .. ^1].toUpperAscii()
|
||||||
|
|
@ -366,5 +366,3 @@ when isMainModule:
|
||||||
doAssert testTitleCase.hasKey("Content-Length")
|
doAssert testTitleCase.hasKey("Content-Length")
|
||||||
for key, val in testTitleCase:
|
for key, val in testTitleCase:
|
||||||
doAssert key == "Content-Length"
|
doAssert key == "Content-Length"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue