New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to remove STRLEN() part 5 #14648
Conversation
I suspect you really want to rebase this branch on to the latest master rather than merging in master on top of other commits which have presumably already been merged here? The diff indicates this patch series also adds some uses of |
Yes I think you're right. I probably should rebase. Yes some calls to STRLEN() have been added. |
Yes, if possible, please try to rebase and get rid of all previously merged changes. That helps. |
Sorry to be a pain, but can someone please give me instructions on the best way to rebase? I have been looking around online and just got myself confused. Thanks. |
@basilisk0315 what you want to do is something like (assuming you are on the branch of interest):
If you have a remote
You'll have to |
Thanks for the info @benknoble. I hope I have done it correctly. |
src/regexp.c
Outdated
* Get length of line "lnum", which is relative to "reg_firstlnum". | ||
*/ | ||
static colnr_T | ||
reg_getlinelen(linenr_T lnum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use _len
suffix typically, so I think this deserves to be reg_getline_len()
as well
char_u *p; | ||
char_u *newsub = source; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't move this line
src/regexp.c
Outdated
char_u *p; | ||
char_u *newsub = source; | ||
size_t newsublen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can go with size_t newsublen = 0
;
src/regexp.c
Outdated
size_t postfixlen; | ||
size_t tmpsublen; | ||
|
||
if (!have_newsublen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here: if (newsublen == 0)
then we don't need the have_newsublen
var
rex.reg_firstlnum = save_first; | ||
rex.reg_maxline = save_max; | ||
return len; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates code with the function above reg_getline_submatch()
. Can we refactor both into a a common function?
thanks, I had to wrap my head around several times for some of the pointer arithmethics :/ but I think I got it now. If you could please refactor |
Hi Christian, no worries. Stay tuned... |
thanks! |
Refactor regexp.c, regexp_bt.c and regexp_nfa.c to remove STRLEN() calls.
At the same time improve the efficiency of character class lookups in function get_char_class().
My measurements on an empty buffer show no difference in the number of comparisons (~100). This is because my start up files use '[[:alnum:]]' almost exclusively. However, each comparison originally included a call to STRLEN() and STRNCMP(). After the change each comparison only uses STRNCMP().
Cheers
John