diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-21 09:24:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-21 09:24:09 +0800 |
commit | e86d2734a93e159d44df8132dee6b994e5922d18 (patch) | |
tree | e8a3015ebc88d880f9e749a7e69fbcf0d8793037 /src/nvim/eval.c | |
parent | 1c16d0994d08f1a6c396bc46833d0bfdade29422 (diff) | |
download | rneovim-e86d2734a93e159d44df8132dee6b994e5922d18.tar.gz rneovim-e86d2734a93e159d44df8132dee6b994e5922d18.tar.bz2 rneovim-e86d2734a93e159d44df8132dee6b994e5922d18.zip |
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.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 45b492be80..4392ea306f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1648,7 +1648,7 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool // the end is an error otherwise. if (lp->ll_n1 < gap->ga_len || lp->ll_n1 == gap->ga_len) { ga_grow(&lp->ll_blob->bv_ga, 1); - tv_blob_set(lp->ll_blob, (int)lp->ll_n1, (char_u)val); + tv_blob_set(lp->ll_blob, (int)lp->ll_n1, (uint8_t)val); if (lp->ll_n1 == gap->ga_len) { gap->ga_len++; } @@ -2660,10 +2660,10 @@ static int eval5(char **arg, typval_T *rettv, int evaluate) blob_T *const b = tv_blob_alloc(); for (int i = 0; i < tv_blob_len(b1); i++) { - ga_append(&b->bv_ga, (char)tv_blob_get(b1, i)); + ga_append(&b->bv_ga, tv_blob_get(b1, i)); } for (int i = 0; i < tv_blob_len(b2); i++) { - ga_append(&b->bv_ga, (char)tv_blob_get(b2, i)); + ga_append(&b->bv_ga, tv_blob_get(b2, i)); } tv_clear(rettv); @@ -3688,7 +3688,7 @@ static int get_number_tv(char **arg, typval_T *rettv, bool evaluate, bool want_s return FAIL; } if (blob != NULL) { - ga_append(&blob->bv_ga, (char)((hex2nr(*bp) << 4) + hex2nr(*(bp + 1)))); + ga_append(&blob->bv_ga, (uint8_t)((hex2nr(*bp) << 4) + hex2nr(*(bp + 1)))); } if (bp[2] == '.' && ascii_isxdigit(bp[3])) { bp++; @@ -4881,7 +4881,7 @@ void filter_map(typval_T *argvars, typval_T *rettv, int map) } if (map) { if (tv.vval.v_number != val) { - tv_blob_set(b, i, (char_u)tv.vval.v_number); + tv_blob_set(b, i, (uint8_t)tv.vval.v_number); } } else if (rem) { char *const p = argvars[0].vval.v_blob->bv_ga.ga_data; |