forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb31e3f5
committed
Improve worst-case performance of text_position_get_match_pos()
This function converts a byte position to a character position aftera successful string match. Rather than calling pg_mblen() in a loop,use pg_mbstrlen_with_len() since the latter can inline its own call topg_mblen(). When the string match is at the end of the haystack text, thischange results in 10-20% performance improvement, depending on platform andtypical character length in bytes. This also simplifies the code a little.Specializing for UTF-8 could result in further improvement, but theperformance gain was not found to be reliable between platforms. The modestgain in this commit is stable between platforms and usable by all serverencodings.Discussion:https://www.postgresql.org/message-id/CAFBsxsH1Yutrmu+6LLHKK8iXY+vG--Do6zN+2900spHXQNNQKQ@mail.gmail.com1 parent807fee1 commitb31e3f5
1 file changed
+5
-23
lines changedLines changed: 5 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
54 |
| - | |
55 | 54 |
| |
56 | 55 |
| |
57 | 56 |
| |
| |||
1221 | 1220 |
| |
1222 | 1221 |
| |
1223 | 1222 |
| |
1224 |
| - | |
1225 |
| - | |
1226 | 1223 |
| |
1227 |
| - | |
1228 | 1224 |
| |
1229 |
| - | |
1230 |
| - | |
1231 | 1225 |
| |
1232 |
| - | |
1233 | 1226 |
| |
1234 |
| - | |
1235 |
| - | |
1236 | 1227 |
| |
1237 |
| - | |
1238 | 1228 |
| |
1239 | 1229 |
| |
1240 | 1230 |
| |
| |||
1466 | 1456 |
| |
1467 | 1457 |
| |
1468 | 1458 |
| |
1469 |
| - | |
1470 |
| - | |
1471 |
| - | |
1472 |
| - | |
1473 |
| - | |
1474 |
| - | |
1475 |
| - | |
1476 |
| - | |
1477 |
| - | |
1478 |
| - | |
1479 |
| - | |
1480 |
| - | |
1481 |
| - | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1482 | 1464 |
| |
1483 | 1465 |
| |
1484 | 1466 |
| |
|
0 commit comments
Comments
(0)