struct LuckyRouter::PathSegment

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.cr

Constant Summary

PERCENT = '%'.ord.to_u8
SLASH = '/'.ord.to_u8

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(path : String, offset : Int32, length : Int32) #

[View source]

Class Method Detail

def self.glob_value(path : String, offset : Int32) : String #

[View source]
def self.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.


[View source]
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.


[View source]

Instance Method Detail

def ==(other : String) : Bool #

[View source]
def hash(hasher) #
Description copied from struct Struct

See Object#hash(hasher)


[View source]
def length : Int32 #

[View source]
def offset : Int32 #

[View source]
def path : String #

[View source]
def to_slice : Bytes #

[View source]
def to_unsafe : Pointer(UInt8) #

[View source]
def value : String #

[View source]