]> git.feebdaed.xyz Git - 0xmirror/vim.git/commit
patch 9.1.1983: Vim9: class_name definition can be improved
authorJohn Marriott <basilisk@internode.on.net>
Mon, 15 Dec 2025 20:09:29 +0000 (21:09 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 15 Dec 2025 20:09:29 +0000 (21:09 +0100)
commit2019321e0be320183afa47b7ea979dc4fc3984a0
treef88f1059a6478b90a8dd14a43116256e0eea645b
parenteb5995a8764418359b979093f3af06f03ac7de6e
patch 9.1.1983: Vim9: class_name definition can be improved

Problem:  Vim9: class_name definition can be improved
Solution: Use string_T to store class_name, avoid using STRLEN() calls,
          simplify code, remove unused definition of struct
          oc_newmember_S (John Marriott)

Use struct string_T to store the field class_name in struct class_T,
which means we can just use the .length field in struct string_T
instead of measuring it.

In addition:
1. In eval.c use string_T to store class_name and s in function
   class_tv2string().
2. In vim9type.c change some calls from ga_concat() to ga_concat_len()
   where the length is known.
3. In vim9class.c remove unused struct definition oc_newmember_S.
   Change some calls from ga_concat() to ga_concat_len() where the
   length is known.
4. In scriptfile.c use string_T to store type_name, class_name and
   es_name in function estack_sfile().
5. In function estack_sfile() simplify construction of the grow array ga
   and change some calls from ga_concat() to ga_concat_len() when the
   length is known.

closes: #18925

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
13 files changed:
src/eval.c
src/evalvars.c
src/scriptfile.c
src/structs.h
src/typval.c
src/userfunc.c
src/version.c
src/vim9class.c
src/vim9cmds.c
src/vim9compile.c
src/vim9execute.c
src/vim9expr.c
src/vim9type.c