simplified blank hashtables serialization

This commit is contained in:
Timerix22 2022-05-03 01:16:55 +03:00
parent 28e654ce5a
commit 448b69c8e9
2 changed files with 19 additions and 4 deletions

View File

@ -74,6 +74,20 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){
}
break;
case HashtablePtr:
// check hashtable is blank
Hashtable_foreach(((Hashtable*)u.VoidPtr), __, ({
goto hashtableNotBlank;
if(__.key); // weird way to disable warning
}));
// blank hashtable
addc('{');
addc('}');
break;
// not blank hashtable
hashtableNotBlank:
addc('\n');
AppendTabs();
addc('{');

View File

@ -11,7 +11,8 @@ const char text[]=
" double: 965.557f;#another comment!\n"
" text: \"_$\\\"\\\\'''a ыыы000;2;=:%d;```\";\n"
" list: [10,20,30,0,0 ];"
"};";
"};"
"h: { };";
void print_dtsod(Hashtable* dtsod){
printf("\e[92m");
@ -47,7 +48,7 @@ void test_dtsod(){
tryLast(DtsodV24_serialize(dtsod),r)
s=r.value.VoidPtr;
}));
Hashtable_free(dtsod);
DtsodV24_free(dtsod);
printf("\e[92m%s",s);
optime("reserialize",10,({
@ -56,7 +57,7 @@ void test_dtsod(){
free(s);
tryLast(DtsodV24_serialize(dtsod),rr)
s=rr.value.VoidPtr;
Hashtable_free(dtsod);
DtsodV24_free(dtsod);
}));
free(s);