mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
refactor: use uint8_t for blobs and ga_append() (#21916)
A blob is used as a sequence of bytes and usually accessed individually, not as as a NUL-terminuated string, so uint8_t should be better. Not sure about ga_append(), but using uint8_t leads to fewer casts.
This commit is contained in:
@@ -2730,7 +2730,7 @@ void tv_blob_remove(typval_T *argvars, typval_T *rettv, const char *arg_errmsg)
|
||||
}
|
||||
if (argvars[2].v_type == VAR_UNKNOWN) {
|
||||
// Remove one item, return its value.
|
||||
char_u *const p = (char_u *)b->bv_ga.ga_data;
|
||||
uint8_t *const p = (uint8_t *)b->bv_ga.ga_data;
|
||||
rettv->vval.v_number = (varnumber_T)(*(p + idx));
|
||||
memmove(p + idx, p + idx + 1, (size_t)(len - idx - 1));
|
||||
b->bv_ga.ga_len--;
|
||||
@@ -2752,9 +2752,8 @@ void tv_blob_remove(typval_T *argvars, typval_T *rettv, const char *arg_errmsg)
|
||||
blob->bv_ga.ga_len = (int)(end - idx + 1);
|
||||
ga_grow(&blob->bv_ga, (int)(end - idx + 1));
|
||||
|
||||
char_u *const p = (char_u *)b->bv_ga.ga_data;
|
||||
memmove((char_u *)blob->bv_ga.ga_data, p + idx,
|
||||
(size_t)(end - idx + 1));
|
||||
uint8_t *const p = (uint8_t *)b->bv_ga.ga_data;
|
||||
memmove(blob->bv_ga.ga_data, p + idx, (size_t)(end - idx + 1));
|
||||
tv_blob_set_ret(rettv, blob);
|
||||
|
||||
if (len - end - 1 > 0) {
|
||||
|
Reference in New Issue
Block a user