[Github-comments] [geany/geany] Enable local variables for C/C++ and improve autocompletion (PR #3185)

Jiří Techet notifications at github.com
Mon May 2 21:43:33 UTC 2022


@techee commented on this pull request.



> +		!(tag->type & tm_tag_local_var_t) &&
+		is_autocomplete_tag(tag, info);
+}
+
+
+static guint copy_tags(GPtrArray *dst, TMTag **src, guint src_len, GHashTable *name_table,
+	gint num, gboolean (*predicate) (TMTag *, CopyInfo *), CopyInfo *info)
+{
+	guint i;
+
+	g_return_val_if_fail(src && dst, 0);
+
+	for (i = 0; i < src_len && num > 0; i++)
+	{
+		TMTag *tag = *src;
+		if (predicate(tag, info) &&

> Regardless of the order, IMO the call to is_autocomplete_tag() doesn't need to be duplicated in each predicate function but can be called in one place here, especially if the compiler whats to inline it.

Agree.

And if performance is your concern, we can actually do better. I didn't think of it when writing the patch but these calls 
```
		copy_tags(dst, found, count, name_table, max_num - dst->len, is_local_tag, info);
		copy_tags(dst, found, count, name_table, max_num - dst->len, is_current_file_tag, info);
		copy_tags(dst, found, count, name_table, max_num - dst->len, is_header_file_tag, info);
```
could be modified not to perform on the workspace tags but only the tags from the current file or the current header (that is, from `info->file->tags_array` or `info->header->tags_array` (of course after performing tm_tags_find() on them before). That should speed up the search for local tags, current file's tags and header (and possibly include) tags significantly.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3185#discussion_r863211941
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3185/review/959595016 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20220502/2103f715/attachment.htm>


More information about the Github-comments mailing list