Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122348 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66546 invoked from network); 8 Feb 2024 19:10:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Feb 2024 19:10:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707419461; bh=9OZhLTcIoq6Acp1mkpRaS4rVkwonzGhh6j55uQqqpKw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Y0zPusxnqVHf6NciRufikKnRS/8d9E1gFtx7z1tHjw0guv3Fd0GzNhUEo0FRT8dYv f0uk6axicOL17bxyJjSw1uZaAf7FMaCytsRai3gUSKnj4XxzAO4huTlz3t/q/zHDx8 LMZHPtL5kC+m+kAKaa4WWo1Ayeav9T3WnRq7Lkw99KWCQ0McECxBDuFVj/Dd9KZIU5 iWELg0D2v/vOQ4aLl94w8QSLYIUeKB/v7nf4y1PSHhpgUHcS26HK08Qe4gxhzhsh3e Fxz+/PzQoL1QJRFM0g6oQYf1M2o2Ptsdsyd5EhhxVPdtsS7IlPm7i6QTRm+toiVfmQ OuRXmKG3SBOig== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 319E218005C for ; Thu, 8 Feb 2024 11:11:01 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 8 Feb 2024 11:11:00 -0800 (PST) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-33b436dbdcfso25995f8f.0 for ; Thu, 08 Feb 2024 11:10:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707419406; x=1708024206; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9OZhLTcIoq6Acp1mkpRaS4rVkwonzGhh6j55uQqqpKw=; b=Ze0CymS9Y4vyo4RtB8qOMERPv5NniZHFrJvggZ2TWM93SciRQfwfKty8l45mc9rNSu IbNJxTIo/aqP4P3mt0Br4jXla0zwGmh6bTPIE/gwV7syoUvGsN8JgCtpGXJopfqmv62I EBBz8dF0kR3VjbiTuBS6Q7ksxMlD/0EfrRt7I9myGbrAIUbjM6tlT845/toU402j661n L1Mnd8G4y2WVR8CY4tqpqUKEpaQWjx9MB60OSu1Duc3kyi1p01wXjxfJYXNMgJeOsBgJ 0wRebwMhaUxh6KU6hDJz+hmetsS6cb6Ecc4RwrzYB9RQDu4gFd+eP0zYqq/5S0TNAdJf g34Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707419406; x=1708024206; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9OZhLTcIoq6Acp1mkpRaS4rVkwonzGhh6j55uQqqpKw=; b=kCxCXDuto0o0hxWEcHcl8n/11aOjfra7WnPwdKhatP6qUe8mZYPsE4yBYe0iTg9QRa 03GZqTfwWhEiPD3Hf5GMRHEDe1a2X6+NoJf6rh2aBTv6uQ+GbaOlx722fr+ypByP28PR +0VeDFUYKyMqziztQSgCrWfQ44AAx4EtbiKB+QknzpGYk3nBfYDfBBWR3/BVbmjwdots eHx7WNIrvEmV4JL0ESuSutGWv7AZPYeEkerLBnOeCXUd8YVfhA7k2Gn/mt9kpSL4N5Ej cvhg6okL+lN3r+vmKDmhe3PBx9ig+RPm0/qdcVLU91CDiw859iOQ3BJCgR9FPdCKH2yB dgaA== X-Gm-Message-State: AOJu0YyHwxX7KcI0+ozkGJT9MlcrGE2fdVVhP5tttVzS8UEFzNlxEEjE Ps7O8fdvhecR9IJtfY18FeFYc07VKdMbbgn1VzCwd6y61hpz7i9GZdnGwVsAjWKrFD+hCHDRHNe 1oyYHcRpiDSw7IUleXH5Iaga3pW8= X-Google-Smtp-Source: AGHT+IGXA/fK85se2TODb/Sicp85Rx8oxntPMP8/UwhpH2ph2LorGMlsbH7MMFpxwW/iNLwigBzAPGcoOoEXcl77Fd0= X-Received: by 2002:adf:a342:0:b0:33b:4b08:65d6 with SMTP id d2-20020adfa342000000b0033b4b0865d6mr290884wrb.51.1707419405511; Thu, 08 Feb 2024 11:10:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 8 Feb 2024 14:09:53 -0500 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= Cc: PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Why are serialized strings wrapped in double quotes? (s::"") From: figureonecpr@gmail.com (Sanford Whiteman) Hi Micha=C5=82, 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' 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. =E2=80=94 S.