compare StringChunkList with String struct
This commit is contained in:
@@ -878,6 +878,7 @@ fn void stringChunkListDeleteLast(StringArena* a, StringChunkList* list);
|
|||||||
fn StringChunkList stringChunkListInit(StringArena* a);
|
fn StringChunkList stringChunkListInit(StringArena* a);
|
||||||
fn void stringChunkCopyToBuffer(StringChunkList* list, u8* buffer, u32 len);
|
fn void stringChunkCopyToBuffer(StringChunkList* list, u8* buffer, u32 len);
|
||||||
fn bool stringChunkListsEq(StringChunkList* a, StringChunkList* b);
|
fn bool stringChunkListsEq(StringChunkList* a, StringChunkList* b);
|
||||||
|
fn bool stringChunkListEqString(StringChunkList* a, String* b);
|
||||||
|
|
||||||
///// BINARY SERIALIZATION NONSENSE
|
///// BINARY SERIALIZATION NONSENSE
|
||||||
fn u64 writeU64ToBufferLE(u8* buffer, u64 value);
|
fn u64 writeU64ToBufferLE(u8* buffer, u64 value);
|
||||||
|
|||||||
@@ -182,3 +182,17 @@ fn bool stringChunkListsEq(StringChunkList* a, StringChunkList* b) {
|
|||||||
return true;
|
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