Skip to content

Commit 0ab0104

Browse files
committed
lldb: refactor print_vec_slice_val
Be more idiomatic and rely less on fiddly construction of output
1 parent 125677e commit 0ab0104

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/etc/lldb_rust_formatters.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def print_struct_val(val, internal_dict):
4343
return print_struct_val_starting_from(0, val, internal_dict)
4444

4545
def print_vec_slice_val(val, internal_dict):
46-
output = "&["
47-
4846
length = val.GetChildAtIndex(1).GetValueAsUnsigned()
4947

5048
data_ptr_val = val.GetChildAtIndex(0)
@@ -56,16 +54,12 @@ def print_vec_slice_val(val, internal_dict):
5654

5755
start_address = data_ptr_val.GetValueAsUnsigned()
5856

59-
for i in range(length):
57+
def render_element(i):
6058
address = start_address + i * element_type_size
61-
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type )
62-
output += print_val(element_val, internal_dict)
63-
64-
if i != length - 1:
65-
output += ", "
59+
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type)
60+
return print_val(element_val, internal_dict)
6661

67-
output += "]"
68-
return output
62+
return "&[%s]" % (', '.join([render_element(i) for i in range(length)]))
6963

7064
def print_struct_val_starting_from(field_start_index, val, internal_dict):
7165
'''

0 commit comments

Comments
 (0)