simplified blank hashtables serialization
This commit is contained in:
parent
28e654ce5a
commit
448b69c8e9
@ -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('{');
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user