compare StringChunkList with String struct

This commit is contained in:
Tenari
2026-08-21 08:13:19 -05:00
parent 716d165e2d
commit 756b83aeee
2 changed files with 15 additions and 0 deletions
+14
View File
@@ -182,3 +182,17 @@ fn bool stringChunkListsEq(StringChunkList* a, StringChunkList* b) {
return true;
}
fn bool stringChunkListEqString(StringChunkList* a, String* b) {
if (a->total_size != b->length) return false;
StringChunk* chunk = a->first;
for (u32 i = 0; i < a->total_size; i++) {
if (i > 0 && i % STRING_CHUNK_PAYLOAD_SIZE == 0) {
chunk = chunk->next;
}
u8 a_char = *((char*)(chunk + 1) + (i%STRING_CHUNK_PAYLOAD_SIZE));
u8 b_char = b->bytes[i];
if (a_char != b_char) return false;
}
return true;
}