Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29CD3C07E96 for ; Tue, 6 Jul 2021 16:37:23 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FB5361C3C for ; Tue, 6 Jul 2021 16:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FB5361C3C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4B8782DA2; Tue, 6 Jul 2021 18:37:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DMgNoc1t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 00F5F82DA0; Tue, 6 Jul 2021 18:37:05 +0200 (CEST) Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 568E382D94 for ; Tue, 6 Jul 2021 18:37:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x335.google.com with SMTP id 75-20020a9d08510000b02904acfe6bcccaso2067755oty.12 for ; Tue, 06 Jul 2021 09:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AdkXlsNjqGeYxScpo3C9A4U1YqyCRvRw410Szw/z+eM=; b=DMgNoc1t941b8hQhi8XyL3DgGX8sR9l8E6T6pco5SOGw6qS53L4ISx12fDV7GO0S2u ct6caYlfI9FLb0K7Gbheyea6i3FV4j7SkgFxsjeAL6Ju2kEOdk3+oh2EMvZsASrx1Hk/ Plz6ZatTTEM4Y9tPMgp/Bo/DUF4LC1qvQIsKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AdkXlsNjqGeYxScpo3C9A4U1YqyCRvRw410Szw/z+eM=; b=rykOUlWcCir3kSg0XMfJFPjdXvy+HLzKYuZfrmZgOF6jLJ3Nl96PfhtAab95fC9FZD jPcdcvcIMFJgeP+j/1i4hh/AG236TsPsZb3JBMMerHNuDonRpCaG94RLJ5jzBSHih1bB AGz7BDLzQVPWA66rDEWmsNw3S7L1vGttLdsX1VA62Ih6T5lDpAUPTxxgwGohlvzmnfjq 1LgnzX065DVXiGt02QJdFLNwEDKIxdPbaWqulBrWVd01Cj8Vb1ZnD+2tYHP7QEx5AHBI 9kYFeSv0yvUTUevDVkup+FZ4wPzxzO1V5K8P37A2xo0VUfOcTTzshDzzkNY95oAsiCYN K0mg== X-Gm-Message-State: AOAM532OpC07Qv/2VuJB3XCo0mU6O3+I65Vhf2DFs26amUsjZBzH+607 Q37EAhU1YRZyMLQIgTglc5UnzybkdcSgmgF3 X-Google-Smtp-Source: ABdhPJwywm8aFDvJKt00ZLBDEeW1XIBgVhF/pi8QKT0cwkEln7WlQ9fY3bR0ho45sEN57xcZYgIAdA== X-Received: by 2002:a05:6830:130e:: with SMTP id p14mr15670155otq.351.1625589418863; Tue, 06 Jul 2021 09:36:58 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id e74sm3336357ote.14.2021.07.06.09.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 09:36:58 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alper Nebi Yasak , Bin Meng Subject: [PATCH 4/6] binman: Use bytearray instead of string Date: Tue, 6 Jul 2021 10:36:39 -0600 Message-Id: <20210706163641.2280401-5-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210706163641.2280401-1-sjg@chromium.org> References: <20210706163641.2280401-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This is faster if data is being concatenated. Update the section and collection etypes. Signed-off-by: Simon Glass --- tools/binman/etype/collection.py | 2 +- tools/binman/etype/section.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/binman/etype/collection.py b/tools/binman/etype/collection.py index 1625575fe98..442b40b48b3 100644 --- a/tools/binman/etype/collection.py +++ b/tools/binman/etype/collection.py @@ -40,7 +40,7 @@ class Entry_collection(Entry): """ # Join up all the data self.Info('Getting contents, required=%s' % required) - data = b'' + data = bytearray() for entry_phandle in self.content: entry_data = self.section.GetContentsByPhandle(entry_phandle, self, required) diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 92d3f3add4c..e2949fc9163 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -166,7 +166,7 @@ class Entry_section(Entry): pad_byte = (entry._pad_byte if isinstance(entry, Entry_section) else self._pad_byte) - data = b'' + data = bytearray() # Handle padding before the entry if entry.pad_before: data += tools.GetBytes(self._pad_byte, entry.pad_before) @@ -200,7 +200,7 @@ class Entry_section(Entry): Returns: Contents of the section (bytes) """ - section_data = b'' + section_data = bytearray() for entry in self._entries.values(): entry_data = entry.GetData(required) -- 2.32.0.93.g670b81a890-goog