MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / sz_fill_serial

Function sz_fill_serial

include/stringzilla/memory.h:321–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319#pragma optimize("", off)
320#endif
321SZ_PUBLIC void sz_fill_serial(sz_ptr_t target, sz_size_t length, sz_u8_t value) {
322 sz_ptr_t end = target + length;
323 // Dealing with short strings, a single sequential pass would be faster.
324 // If the size is larger than 2 words, then at least 1 of them will be aligned.
325 // But just one aligned word may not be worth SWAR.
326 if (length < SZ_SWAR_THRESHOLD)
327 while (target != end) *(target++) = value;
328
329 // In case of long strings, skip unaligned bytes, and then fill the rest in 64-bit chunks.
330 else {
331 sz_u64_t value64 = (sz_u64_t)value * 0x0101010101010101ull;
332 while ((sz_size_t)target & 7ull) *(target++) = value;
333 while (target + 8 <= end) *(sz_u64_t *)target = value64, target += 8;
334 while (target != end) *(target++) = value;
335 }
336}
337#if defined(_MSC_VER) && defined(SZ_OVERRIDE_LIBC) && SZ_OVERRIDE_LIBC
338#pragma optimize("", on)
339#endif

Callers 3

sz_fill_haswellFunction · 0.85
sz_fill_neonFunction · 0.85
sz_fillFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…