Skip to content

Commit

Permalink
Make use of new xmemrchr() portability wrapper in strview_memrchr()
Browse files Browse the repository at this point in the history
See also: commit 1096839
  • Loading branch information
craigbarnes committed Dec 23, 2024
1 parent 3099ba9 commit cb65ec1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/util/string-view.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ascii.h"
#include "debug.h"
#include "macros.h"
#include "xmemrchr.h"
#include "xstring.h"

// A non-owning, length-bounded "view" into another string, similar to
Expand Down Expand Up @@ -143,15 +144,7 @@ static inline const unsigned char *strview_memchr(const StringView *sv, int c)
NONNULL_ARGS
static inline const unsigned char *strview_memrchr(const StringView *sv, int c)
{
const unsigned char *s = sv->data;
size_t n = sv->length;
c = (int)(unsigned char)c;
while (n--) {
if (s[n] == c) {
return (s + n);
}
}
return NULL;
return sv->length ? xmemrchr(sv->data, c, sv->length) : NULL;
}

NONNULL_ARGS
Expand Down
1 change: 1 addition & 0 deletions src/util/strtonum.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ bool str_to_filepos(const char *str, size_t *linep, size_t *colp)
return r;
}

// Return the number of decimal digits in `x`
size_t size_str_width(size_t x)
{
size_t width = 0;
Expand Down

0 comments on commit cb65ec1

Please sign in to comment.