Skip to content

Commit 41c6bbe

Browse files
authored
Merge pull request numpy#27612 from fengluoqiuwu/comment_string_fastsearch
ENH: Add comments to `string_fastsearch.h` , rename some C-methods
2 parents 020e78c + 78760de commit 41c6bbe

File tree

2 files changed

+579
-119
lines changed

2 files changed

+579
-119
lines changed

numpy/_core/src/umath/string_buffer.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ string_find(Buffer<enc> buf1, Buffer<enc> buf2, npy_int64 start, npy_int64 end)
866866
{
867867
char ch = *buf2;
868868
CheckedIndexer<char> ind(start_loc, end_loc - start_loc);
869-
result = (npy_intp) findchar(ind, end_loc - start_loc, ch);
869+
result = (npy_intp) find_char(ind, end_loc - start_loc, ch);
870870
if (enc == ENCODING::UTF8 && result > 0) {
871871
result = utf8_character_index(
872872
start_loc, start_loc - buf1.buf, start, result,
@@ -878,7 +878,7 @@ string_find(Buffer<enc> buf1, Buffer<enc> buf2, npy_int64 start, npy_int64 end)
878878
{
879879
npy_ucs4 ch = *buf2;
880880
CheckedIndexer<npy_ucs4> ind((npy_ucs4 *)(buf1 + start).buf, end-start);
881-
result = (npy_intp) findchar(ind, end - start, ch);
881+
result = (npy_intp) find_char(ind, end - start, ch);
882882
break;
883883
}
884884
}
@@ -970,7 +970,7 @@ string_rfind(Buffer<enc> buf1, Buffer<enc> buf2, npy_int64 start, npy_int64 end)
970970
{
971971
char ch = *buf2;
972972
CheckedIndexer<char> ind(start_loc, end_loc - start_loc);
973-
result = (npy_intp) rfindchar(ind, end_loc - start_loc, ch);
973+
result = (npy_intp) rfind_char(ind, end_loc - start_loc, ch);
974974
if (enc == ENCODING::UTF8 && result > 0) {
975975
result = utf8_character_index(
976976
start_loc, start_loc - buf1.buf, start, result,
@@ -982,7 +982,7 @@ string_rfind(Buffer<enc> buf1, Buffer<enc> buf2, npy_int64 start, npy_int64 end)
982982
{
983983
npy_ucs4 ch = *buf2;
984984
CheckedIndexer<npy_ucs4> ind((npy_ucs4 *)(buf1 + start).buf, end - start);
985-
result = (npy_intp) rfindchar(ind, end - start, ch);
985+
result = (npy_intp) rfind_char(ind, end - start, ch);
986986
break;
987987
}
988988
}
@@ -1236,14 +1236,14 @@ string_lrstrip_chars(Buffer<enc> buf1, Buffer<enc> buf2, Buffer<enc> out, STRIPT
12361236
case ENCODING::ASCII:
12371237
{
12381238
CheckedIndexer<char> ind(buf2.buf, len2);
1239-
res = findchar<char>(ind, len2, *traverse_buf);
1239+
res = find_char<char>(ind, len2, *traverse_buf);
12401240
break;
12411241
}
12421242
case ENCODING::UTF8:
12431243
{
12441244
if (current_point_bytes == 1) {
12451245
CheckedIndexer<char> ind(buf2.buf, len2);
1246-
res = findchar<char>(ind, len2, *traverse_buf);
1246+
res = find_char<char>(ind, len2, *traverse_buf);
12471247
} else {
12481248
res = fastsearch(buf2.buf, buf2.after - buf2.buf,traverse_buf.buf, current_point_bytes, -1, FAST_SEARCH);
12491249
}
@@ -1252,7 +1252,7 @@ string_lrstrip_chars(Buffer<enc> buf1, Buffer<enc> buf2, Buffer<enc> out, STRIPT
12521252
case ENCODING::UTF32:
12531253
{
12541254
CheckedIndexer<npy_ucs4> ind((npy_ucs4 *)buf2.buf, len2);
1255-
res = findchar<npy_ucs4>(ind, len2, *traverse_buf);
1255+
res = find_char<npy_ucs4>(ind, len2, *traverse_buf);
12561256
break;
12571257
}
12581258
}
@@ -1280,14 +1280,14 @@ string_lrstrip_chars(Buffer<enc> buf1, Buffer<enc> buf2, Buffer<enc> out, STRIPT
12801280
case ENCODING::ASCII:
12811281
{
12821282
CheckedIndexer<char> ind(buf2.buf, len2);
1283-
res = findchar<char>(ind, len2, *traverse_buf);
1283+
res = find_char<char>(ind, len2, *traverse_buf);
12841284
break;
12851285
}
12861286
case ENCODING::UTF8:
12871287
{
12881288
if (current_point_bytes == 1) {
12891289
CheckedIndexer<char> ind(buf2.buf, len2);
1290-
res = findchar<char>(ind, len2, *traverse_buf);
1290+
res = find_char<char>(ind, len2, *traverse_buf);
12911291
} else {
12921292
res = fastsearch(buf2.buf, buf2.after - buf2.buf, traverse_buf.buf, current_point_bytes, -1, FAST_RSEARCH);
12931293
}
@@ -1296,7 +1296,7 @@ string_lrstrip_chars(Buffer<enc> buf1, Buffer<enc> buf2, Buffer<enc> out, STRIPT
12961296
case ENCODING::UTF32:
12971297
{
12981298
CheckedIndexer<npy_ucs4> ind((npy_ucs4 *)buf2.buf, len2);
1299-
res = findchar<npy_ucs4>(ind, len2, *traverse_buf);
1299+
res = find_char<npy_ucs4>(ind, len2, *traverse_buf);
13001300
break;
13011301
}
13021302
}
@@ -1331,7 +1331,7 @@ findslice_for_replace(CheckedIndexer<char_type> buf1, npy_intp len1,
13311331
return 0;
13321332
}
13331333
if (len2 == 1) {
1334-
return (npy_intp) findchar(buf1, len1, *buf2);
1334+
return (npy_intp) find_char(buf1, len1, *buf2);
13351335
}
13361336
return (npy_intp) fastsearch(buf1.buffer, len1, buf2.buffer, len2, -1, FAST_SEARCH);
13371337
}

0 commit comments

Comments
 (0)