MCPcopy Index your code
hub / github.com/RustPython/RustPython / rledecode_hqx

Function rledecode_hqx

crates/stdlib/src/binascii.rs:715–744  ·  view source on GitHub ↗
(s: ArgAsciiBuffer)

Source from the content-addressed store, hash-verified

713
714 #[pyfunction]
715 fn rledecode_hqx(s: ArgAsciiBuffer) -> PyResult<Vec<u8>> {
716 const RUN_CHAR: u8 = 0x90; //b'\x90'
717 s.with_ref(|buffer| {
718 let len = buffer.len();
719 let mut out_data = Vec::<u8>::with_capacity(len);
720 let mut idx = 0;
721
722 out_data.push(buffer[idx]);
723 idx += 1;
724
725 while idx < len {
726 if buffer[idx] == RUN_CHAR {
727 if buffer[idx + 1] == 0 {
728 out_data.push(RUN_CHAR);
729 } else {
730 let ch = buffer[idx - 1];
731 let range = buffer[idx + 1];
732 idx += 1;
733 for _ in 1..range {
734 out_data.push(ch);
735 }
736 }
737 } else {
738 out_data.push(buffer[idx]);
739 }
740 idx += 1;
741 }
742 Ok(out_data)
743 })
744 }
745
746 #[pyfunction]
747 fn a2b_uu(s: ArgAsciiBuffer, vm: &VirtualMachine) -> PyResult<Vec<u8>> {

Callers

nothing calls this directly

Calls 3

with_refMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected