MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / slice

Method slice

lib/core/bytes.cc:159–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159Bytes Bytes::slice(unsigned start, unsigned len) const
160{
161 start += _low;
162 unsigned end = start + len;
163 if (start >= _high)
164 {
165 /* Asking for a completely out-of-range slice --- just return zeroes. */
166 return Bytes(len);
167 }
168 else if (end > _high)
169 {
170 /* Can't share the buffer, as we need to zero-pad the end. */
171 Bytes b(len);
172 std::uninitialized_copy(
173 _data->cbegin() + start, _data->cbegin() + _high, b._data->begin());
174 return b;
175 }
176 else
177 {
178 /* Use the magic of shared_ptr to share the data. */
179 Bytes b(_data, start, end);
180 return b;
181 }
182}
183
184Bytes Bytes::slice(unsigned start) const
185{

Callers 15

splitMethod · 0.95
write_sectorFunction · 0.80
decodeSectorRecordMethod · 0.80
decodeSectorRecordMethod · 0.80
decodeDataRecordMethod · 0.80
writeSectorMethod · 0.80
decodeSectorRecordMethod · 0.80
decodeDataRecordMethod · 0.80
decodeSectorRecordMethod · 0.80
encodeMethod · 0.80
decodeSectorRecordMethod · 0.80
decodeDataRecordMethod · 0.80

Calls 3

cbeginMethod · 0.80
BytesClass · 0.70
beginMethod · 0.45

Tested by 3

test_boundsFunction · 0.64
test_equalityFunction · 0.64
test_sliceFunction · 0.64