aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-03-05 20:18:56 -0700
committerSimon Glass <sjg@chromium.org>2022-03-18 19:24:25 -0600
commit0ded4d434dc38031a256eab4428d5e339967dd6b (patch)
treee12d94745e1f34c272cf88f6227efe20680c5781 /tools/dtoc/fdt.py
parentb13114cd216703769ef56a4d1129934380902996 (diff)
downloadu-boot-0ded4d434dc38031a256eab4428d5e339967dd6b.zip
u-boot-0ded4d434dc38031a256eab4428d5e339967dd6b.tar.gz
u-boot-0ded4d434dc38031a256eab4428d5e339967dd6b.tar.bz2
dtoc: Tidy up implementation of AddStringList()
Refactor this to avoid a loop. Also add a test for an empty string. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Diffstat (limited to 'tools/dtoc/fdt.py')
-rw-r--r--tools/dtoc/fdt.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index c16909a..d933972 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -516,9 +516,7 @@ class Node:
Returns:
Prop added
"""
- out = b''
- for string in val:
- out += bytes(string, 'utf-8') + b'\0'
+ out = b'\0'.join(bytes(s, 'utf-8') for s in val) + b'\0' if val else b''
return self.AddData(prop_name, out)
def AddInt(self, prop_name, val):