refactor: reduce number of unique char casts (#15995)

This commit is contained in:
dundargoc
2021-10-12 17:52:54 +02:00
committed by GitHub
parent 64f0fdc682
commit 649b3160a1
29 changed files with 133 additions and 140 deletions

View File

@@ -1903,7 +1903,7 @@ Integer nvim_buf_add_highlight(Buffer buffer, Integer ns_id, String hl_group, In
int hl_id = 0;
if (hl_group.size > 0) {
hl_id = syn_check_group((char_u *)hl_group.data, (int)hl_group.size);
hl_id = syn_check_group(hl_group.data, (int)hl_group.size);
} else {
return ns_id;
}

View File

@@ -1559,7 +1559,7 @@ int object_to_hl_id(Object obj, const char *what, Error *err)
{
if (obj.type == kObjectTypeString) {
String str = obj.data.string;
return str.size ? syn_check_group((char_u *)str.data, (int)str.size) : 0;
return str.size ? syn_check_group(str.data, (int)str.size) : 0;
} else if (obj.type == kObjectTypeInteger) {
return MAX((int)obj.data.integer, 0);
} else {
@@ -1593,7 +1593,7 @@ HlMessage parse_hl_msg(Array chunks, Error *err)
String hl = chunk.items[1].data.string;
if (hl.size > 0) {
// TODO(bfredl): use object_to_hl_id and allow integer
int hl_id = syn_check_group((char_u *)hl.data, (int)hl.size);
int hl_id = syn_check_group(hl.data, (int)hl.size);
attr = hl_id > 0 ? syn_id2attr(hl_id) : 0;
}
}

View File

@@ -195,7 +195,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err)
Integer nvim_get_hl_id_by_name(String name)
FUNC_API_SINCE(7)
{
return syn_check_group((const char_u *)name.data, (int)name.size);
return syn_check_group(name.data, (int)name.size);
}
Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
@@ -227,7 +227,7 @@ Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
void nvim_set_hl(Integer ns_id, String name, Dictionary val, Error *err)
FUNC_API_SINCE(7)
{
int hl_id = syn_check_group( (char_u *)(name.data), (int)name.size);
int hl_id = syn_check_group(name.data, (int)name.size);
int link_id = -1;
HlAttrs attrs = dict2hlattrs(val, true, &link_id, err);