[Github-comments] [geany/geany] Improve goto-symbols popup (#1445)

Matthew Brush notifications at xxxxx
Sat Nov 17 11:14:27 UTC 2018


codebrainz commented on this pull request.



> +	return lcs;
+}
+
+
+/** Transform file names in a list to be shorter.
+ *
+ * This function takes a list of file names (probably with absolute paths), and
+ * transforms the paths such that they are short but still unique. This is intended
+ * for dialogs which present the file list to the user, where the base name may result
+ * in duplicates (showing the full path might be inappropriate).
+ *
+ * The algorthm strips the common prefix (e-g. the user's home directory) and
+ * replaces the longest common substring with an ellipsis ("...").
+ *
+ * @param file_names @array{length=num} The list of strings to process.
+ * @param num The number of strings contained in @a file_names. Can be 0 if it's terminated by @c NULL.

Probably a stupid question (I didn't look at the calling code), but couldn't it use a ready-made collection type like GArray or GPtrArray instead of passing separate arguments? If the parameter isn't modified and the caller does have separate pointer and length, they could just stuff them in a GArray on the stack and pass by const pointer. Or the function could mutate the array in place for better performance. Would also allow to deduplicate the input array without handing back an array that has to be counted by walking through it. Seems cleaner and more efficient than using a plain C array and separate length, but maybe I'm brainwashed by C++ by now, so feel free to ignore :)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1445#discussion_r234405043
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20181117/5891ccd7/attachment.html>


More information about the Github-comments mailing list