From e1d632b1357e5920631d503bc13e992da2580ada Mon Sep 17 00:00:00 2001 From: lda Date: Sat, 18 May 2024 17:11:29 +0200 Subject: [PATCH] [ADD/WIP] Remove boundscheck on array sorts --- Cytoplasm | 2 +- src/CanonicalJson.c | 5 +---- src/State.c | 13 ++----------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Cytoplasm b/Cytoplasm index 5d87da3..346b912 160000 --- a/Cytoplasm +++ b/Cytoplasm @@ -1 +1 @@ -Subproject commit 5d87da31cda74e6808eebca72e9475aabde86532 +Subproject commit 346b912a0633cceac10780b8a103f6c89b5ba89f diff --git a/src/CanonicalJson.c b/src/CanonicalJson.c index b0f2487..5847ef2 100644 --- a/src/CanonicalJson.c +++ b/src/CanonicalJson.c @@ -118,10 +118,7 @@ CanonicalJsonEncode(HashMap * object, Stream * out) ArrayAdd(keys, key); } - if (ArraySize(keys) != 0) - { - ArraySort(keys, CanonicalJsonKeyCompare); - } + ArraySort(keys, CanonicalJsonKeyCompare); /* The total number of bytes written */ length = 0; diff --git a/src/State.c b/src/State.c index 0848a9e..c16dfe2 100644 --- a/src/State.c +++ b/src/State.c @@ -142,13 +142,7 @@ StateResolveV1(Room * room, Array * states) Free(type); Free(key); } - if (ArraySize(events) != 0) - { - /* TODO: Cytoplasm currently doesn't behave correctly - * when the array size is 0, I'll need to file a bug - * report/PR eventually. */ - ArraySort(events, V1Cmp); - } + ArraySort(events, V1Cmp); /* Add first event. */ first = ArrayDelete(events, 0); StateSet( @@ -202,10 +196,7 @@ StateResolveV1(Room * room, Array * states) while (StateIterate(conflicts, &type, &key, (void **) &conflicting)) { - if (ArraySize(conflicting) != 0) - { - ArraySort(conflicting, V1Cmp); - } + ArraySort(conflicting, V1Cmp); for (j = ArraySize(conflicting) - 1; j >= 0; j--) { HashMap *event = ArrayGet(events, j);