compare StringChunkList with String struct
This commit is contained in:
1 parent
716d165e2d
commit
756b83aeee
2 files changed
+15
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user