[vim/vim] Refactor to remove STRLEN() part 6 (PR #14796)

30 views
Skip to first unread message

John Marriott

unread,
May 17, 2024, 6:44:19 PMMay 17
to vim/vim, Subscribed

This PR reduces the number of calls to STRLEN() in search.c. There is nothing tricky here but because all of the call sites needed to change, there are 15 source files involved.

Cheers
John


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/14796

Commit Summary

  • 039fb97 Refactor to remove STRLEN() part 6
  • cd4fa95 Set prefixlen consistently

File Changes

(15 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796@github.com>

John Marriott

unread,
May 17, 2024, 7:00:04 PMMay 17
to vim/vim, Push

@basilisk0315 pushed 1 commit.

  • 6228c97 Fix unsed function errors


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/push/18477550761@github.com>

Christian Brabandt

unread,
May 18, 2024, 9:04:27 AMMay 18
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/cmdhist.c:

> @@ -566,7 +565,7 @@ f_histadd(typval_T *argvars UNUSED, typval_T *rettv)
 	return;
 
     init_history();
-    add_to_history(histype, str, FALSE, NUL);
+    add_to_history(histype, str, STRLEN(str), FALSE, NUL);

Hm, that doesn't seem like a clear improvement here. Instead of calling strlen() inside the function, you'll have to add the strlen() when calling the function.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/review/2064756660@github.com>

John Marriott

unread,
May 19, 2024, 4:12:23 PMMay 19
to vim/vim, Subscribed

@basilisk0315 commented on this pull request.


In src/cmdhist.c:

> @@ -566,7 +565,7 @@ f_histadd(typval_T *argvars UNUSED, typval_T *rettv)
 	return;
 
     init_history();
-    add_to_history(histype, str, FALSE, NUL);
+    add_to_history(histype, str, STRLEN(str), FALSE, NUL);

Yes it looks weird. However, this function is called from five places (including this one) and in the other four places the string's length in known and passed. It's only this one where STRLEN() has to be called.

A similar thing happens for other functions as well.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/review/2065137490@github.com>

Christian Brabandt

unread,
May 20, 2024, 12:36:34 PMMay 20
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/cmdhist.c:

> @@ -566,7 +565,7 @@ f_histadd(typval_T *argvars UNUSED, typval_T *rettv)
 	return;
 
     init_history();
-    add_to_history(histype, str, FALSE, NUL);
+    add_to_history(histype, str, STRLEN(str), FALSE, NUL);

okay thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/review/2066588501@github.com>

Christian Brabandt

unread,
May 20, 2024, 1:22:37 PMMay 20
to vim/vim, Subscribed

Closed #14796 via 8c85a2a.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/issue_event/12868984580@github.com>

zeertzjq

unread,
May 20, 2024, 7:57:45 PMMay 20
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/tag.c:

>  								tagp.tagname);
-			if (!do_search(NULL, '/', '/', pbuf, (long)1,
+			if (!do_search(NULL, '/', '/', pbuf, len, (long)1,

Why is len used here? Shouldn't this be pbuflen?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/review/2067231278@github.com>

zeertzjq

unread,
May 21, 2024, 12:21:36 AMMay 21
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/tag.c:

>  								tagp.tagname);
-			if (!do_search(NULL, '/', '/', pbuf, (long)1,
+			if (!do_search(NULL, '/', '/', pbuf, len, (long)1,

I've created PR #14817 to correct this.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/review/2067485635@github.com>

John Marriott

unread,
May 21, 2024, 6:47:06 AMMay 21
to vim...@googlegroups.com
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/14796/review/2067231278%40github.com.
I think you're right. A typo. Sorry.

Christian Brabandt

unread,
May 21, 2024, 11:19:05 AMMay 21
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/tag.c:

>  								tagp.tagname);
-			if (!do_search(NULL, '/', '/', pbuf, (long)1,
+			if (!do_search(NULL, '/', '/', pbuf, len, (long)1,

sorry, I missed that during review.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14796/review/2068936042@github.com>

Reply all
Reply to author
Forward
0 new messages