From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 20 Dec 2020 03:38:50 +0300 From: "Dmitry V. Levin" To: Alexey Tourbin Message-ID: <20201220003850.GA19293@altlinux.org> References: <20201219224347.230119-1-alexey.tourbin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201219224347.230119-1-alexey.tourbin@gmail.com> Cc: devel@lists.altlinux.org Subject: Re: [devel] [PATCH] pack.c: downgrade XZ->LZMA automatically for small payloads X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Dec 2020 00:38:50 -0000 Archived-At: List-Archive: List-Post: On Sun, Dec 20, 2020 at 01:43:47AM +0300, Alexey Tourbin wrote: > Recent changes left downgradeLzmaLevel dysfunctional (because it does > not recognize 'T'). In my view, the only advantage of XZ over LZMA is > that XZ can can split input into blocks and compress them in parallel > (resulting in a speed-up). Other advantages, such as a checksum, are > immaterial for our purpose (because the package manager must verify the > integrity of a package beforehand). Therefore, downgradeLzmaLevel will > also downgrade XZ->LZMA automatically, for payloads smaller than > 5*dictSize (the default blockSize being 3*dictSize, so that there are > at least two blocks, the second block not too small). > --- > build/pack.c | 54 ++++++++++++++++++++++++++++++++++++++++------------ > 1 file changed, 42 insertions(+), 12 deletions(-) > > diff --git a/build/pack.c b/build/pack.c > index 23ad89e72..a779e7918 100644 > --- a/build/pack.c > +++ b/build/pack.c > @@ -416,30 +416,60 @@ static uint64_t calcArchiveSize(TFI_t fi) > // which is 8-64M. For smaller inputs, levels 7-9 are downgraded automatically. > static void downgradeLzmaLevel(char *mode, uint64_t archiveSize) > { > -#define C(c) if (!(c)) return > - C(mode[1] == '7' || mode[1] == '8' || mode[1] == '9'); > - C(mode[2] == '.'); > - C(mode[3] == 'l' || mode[3] == 'x'); > - C(mode[4] == 'z'); > + if (!(mode[1] >= '0' && mode[1] <= '9')) > + return; > + char *p = &mode[2]; > + if (*p == 'T') { > + do > + p++; > + while (*p >= '0' && *p <= '9'); > + } > + if (!(*p == '.' && (p[1] != 'l' || p[1] == 'x') && p[2] == 'z')) Did you mean p[1] == 'l' here? -- ldv