MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / bytes

Method bytes

atomic-core/examples/compact_semantic_codec/codec.rs:112–136  ·  view source on GitHub ↗
(&mut self, bytes: &[u8], offset: Option<usize>)

Source from the content-addressed store, hash-verified

110 }
111
112 fn bytes(&mut self, bytes: &[u8], offset: Option<usize>) {
113 // Range references never stand in for a token's kind or identity.
114 let (tag, at) = if let Some(at) = offset {
115 if at == self.s.content_cursor {
116 (0, at)
117 } else {
118 (1, at)
119 }
120 } else {
121 let at = *self.literals.entry(bytes.to_vec()).or_insert_with(|| {
122 let at = self.c.literals.len();
123 self.c.literals.extend_from_slice(bytes);
124 at
125 });
126 (2, at)
127 };
128 put(&mut self.c.control, tag);
129 put(&mut self.c.control, bytes.len() as u64);
130 if tag != 0 {
131 delta(&mut self.c.references, &mut self.s.reference, at as u64);
132 }
133 if tag != 2 {
134 self.s.content_cursor = at + bytes.len();
135 }
136 }
137
138 fn leaves(
139 &mut self,

Callers 1

leavesMethod · 0.45

Calls 7

putFunction · 0.70
deltaFunction · 0.70
getFunction · 0.70
undeltaFunction · 0.70
getMethod · 0.65
lenMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected