Hi Michał, Thursday, February 8, 2024, 2:58:52 AM, you wrote:
>You inspired me to play with serialization format to spot even more >unnecessary chars https://3v4l.org/DLh1U >From my PoV there are more candidates to reduce and still keep the safety, >for eg: >removing leading ':' before array/object and trailing ';' inside brackets, >you reduce by 2 bytes > >a:4:{i:0;i:123;i:1;b:1;i:2;d:1.1;i:3;s:3:"baz";} > >Could be simply > >a:4{i:0;i:123;i:1;b:1;i:2;d:1.1;i:3;s:3:baz} > >This example saves 4 bytes: double-quotes, one ; and : > >If you go further all types that require size/length also don't need extra >double-colon meaning: >a:4 could become a4 >s:3 could become s3 > >The same could apply to O: and E: > >O3:Foo:5{s4:date;O17:DateTimeImmutable:3{s4:date;s26:2024-02-08 >08:41:10.009742;s13:timezone_type;i:3;s8:timezone;s16:Europe/Amsterdam}s6:*foo;s11:Foo >bar >baz;s8:Foobar;i:123456789;s3:tbl;a4{i:0;i:123;i:1;b:1;i:2;d:1.1;i:3;s3:baz}s8:*color;E12:Color:Yellow} > >This is still readable by humans and keep the size/length in all places >where needed. Amazing. To my eyes it's more readable too. Here's another one: leading numeral *implies* Integer 'i' (so only 'd', 'b' and 's<len>' are necessary). Or maybe that goes too far. >Interestingly when an array is serialized as object property it is not >followed by ; in field list https://3v4l.org/4p6ve > >O:3:"Foo":2:{s:3:"foo";a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}s:3:"bar";s:3:"baz";} > >Missing ; between }s was a surprise to me. Yeah, that almost seems like a bug that unserialize() tolerates. — S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php