MCPcopy Create free account
hub / github.com/Ray-D-Song/lexe / add_bytecode_header

Function add_bytecode_header

llrt_core/src/bytecode.rs:21–32  ·  view source on GitHub ↗
(bytes: Vec<u8>, file_size: Option<u32>)

Source from the content-addressed store, hash-verified

19
20#[allow(dead_code)]
21pub fn add_bytecode_header(bytes: Vec<u8>, file_size: Option<u32>) -> Vec<u8> {
22 let mut compressed_bytes = Vec::with_capacity(bytes.len());
23 compressed_bytes.extend_from_slice(BYTECODE_VERSION.as_bytes());
24 if let Some(file_size) = file_size {
25 compressed_bytes.push(BYTECODE_COMPRESSED);
26 compressed_bytes.extend_from_slice(&file_size.to_le_bytes());
27 } else {
28 compressed_bytes.push(BYTECODE_UNCOMPRESSED)
29 }
30 compressed_bytes.extend_from_slice(&bytes);
31 compressed_bytes
32}

Callers 3

generate_bytecode_cacheFunction · 0.85
compress_bytecodeFunction · 0.85
compress_moduleFunction · 0.85

Calls 3

pushMethod · 0.80
lenMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected