struct
LuckyRouter::PathSegment
- LuckyRouter::PathSegment
- Struct
- Value
- Object
Overview
A borrowed byte view. Keeping the source String alive makes the view safe throughout traversal, including dynamic backtracking.
Defined in:
lucky_router/path_segment.crConstant Summary
-
PERCENT =
'%'.ord.to_u8 -
SLASH =
'/'.ord.to_u8
Constructors
Class Method Summary
- .glob_value(path : String, offset : Int32) : String
-
.read(path : String, offset : Int32) : Tuple(PathSegment, Int32, Bool)
Scans with a raw pointer and wrapping arithmetic: the loop condition already bounds
index, so per-byte bounds and overflow checks only add branches to the hottest loop in the router. -
.same_bytes?(left : Pointer(UInt8), right : Pointer(UInt8), length : Int32) : Bool
Route literals are short, so a word-at-a-time compare beats a libc call.
Instance Method Summary
- #==(other : String) : Bool
-
#hash(hasher)
See
Object#hash(hasher) - #length : Int32
- #offset : Int32
- #path : String
- #to_slice : Bytes
- #to_unsafe : Pointer(UInt8)
- #value : String
Constructor Detail
Class Method Detail
Scans with a raw pointer and wrapping arithmetic: the loop condition
already bounds index, so per-byte bounds and overflow checks only add
branches to the hottest loop in the router.
def self.same_bytes?(left : Pointer(UInt8), right : Pointer(UInt8), length : Int32) : Bool
#
Route literals are short, so a word-at-a-time compare beats a libc call.
Reads stay inside both buffers because #length bytes remain in each.