py/vstr: Don't check for byte_len>0 in vstr_ins_blank_bytes.

Having this check takes code size and execution time, and it's not
necessary: all callers of this function pass a non-zero value for
`byte_len` already.  And even if `byte_len` was zero, the code would still
perform correctly.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2026-01-04 23:42:40 +11:00
parent 5f59f399b7
commit bfb5e772f1

View File

@@ -188,14 +188,13 @@ char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) {
if (byte_pos > l) {
byte_pos = l;
}
if (byte_len > 0) {
// ensure room for the new bytes
vstr_ensure_extra(vstr, byte_len);
// copy up the string to make room for the new bytes
memmove(vstr->buf + byte_pos + byte_len, vstr->buf + byte_pos, l - byte_pos);
// increase the length
vstr->len += byte_len;
}
// ensure room for the new bytes
vstr_ensure_extra(vstr, byte_len);
// copy up the string to make room for the new bytes
memmove(vstr->buf + byte_pos + byte_len, vstr->buf + byte_pos, l - byte_pos);
// increase the length
vstr->len += byte_len;
// return a pointer to the location to insert new bytes at
return vstr->buf + byte_pos;
}