Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 36040b4

Browse files
committed
refomed get_end_p functions, added tests
1 parent 5bc5595 commit 36040b4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

arraymap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ typedef enum ViewKind{
125125
// Return the end pointer, or the pointer to the location after the last valid character. The end pointer minus the start pointer is the number of characters. For an empty string, all characters are NULL, and the start pointer and end pointer should be equal. NOTE: would like to use strchr(str, '\0') instead of this routine, but some buffers might not have a null terminator and stread by full to the the dt_size.
126126
static inline Py_UCS4*
127127
ucs4_get_end_p(Py_UCS4* p_start, Py_ssize_t dt_size) {
128-
Py_UCS4* p;
129-
for (p = p_start + dt_size - 1; p >= p_start; p--) {
128+
for (Py_UCS4* p = p_start + dt_size - 1; p >= p_start; p--) {
130129
if (*p != '\0') {
131130
return p + 1; // 1 after first non-null
132131
}
@@ -137,8 +136,7 @@ ucs4_get_end_p(Py_UCS4* p_start, Py_ssize_t dt_size) {
137136

138137
static inline char*
139138
char_get_end_p(char* p_start, Py_ssize_t dt_size) {
140-
char* p;
141-
for (p = p_start + dt_size - 1; p >= p_start; p--) {
139+
for (char* p = p_start + dt_size - 1; p >= p_start; p--) {
142140
if (*p != '\0') {
143141
return p + 1; // 1 after first non-null
144142
}

0 commit comments

Comments
 (0)