Skip to main content

str_byte

Function str_byte 

Source
pub fn str_byte(state: &mut LuaState) -> Result<usize, LuaError>
Expand description

string.byte(s [, i [, j]]) — return numeric codes of characters.

C: static int str_byte(lua_State *L)

Borrow the source bytes through to_lua_string (returns a GcRef<LuaString>) instead of check_arg_string (which copies the entire string into a fresh Vec<u8>). On the string_ops_long workload string.byte is called 700k times against the same ~14 KB string, so the previous copy was on the order of 10 GB of memcpy. The GcRef keeps the bytes rooted while the borrow lives.