Repository navigation
Conversation
Replace text_to_cstring(s) + strlen(str) with VARDATA_ANY(s) + src_text_len to avoid one palloc, one memcpy, and one strlen per call. The source byte pointer and its length were already available.
📝 WalkthroughWalkthroughThe four-argument ChangesRegexp count newline scanning
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Related to #1455 |
|
Thanks for your contribution! The change itself looks good, I'll review it shortly. One small request: since IvorySQL is an international community, could you please translate the PR description and the linked issue #1455 into English? That will let more people join the review. |
|
Done. Both the PR description and issue #1455 have been updated to English. Thanks for the reminder. |
|
Nice work! No behavioral difference here though — IvorySQL doesn't support CHR(0). Merging shortly. |
Optimization
The
ora_regexp_countfunction had unnecessary full string copy and scanning when counting newline characters\n:text_to_cstring(s)(palloc+memcpyfull copy) +strlen(str)(full scan)VARDATA_ANY(s)to point to the original bytes directly + reuse the existingsrc_text_len(line 767)Each call saves: 1
palloc+ 1memcpy+ 1 full-stringstrlen.Behavioral difference
Only matters for the edge case where the string contains embedded
\0— the oldstrlentruncates at\0, while the new code uses the real byte length, which is more accurate. Embedded\0in text type is extremely rare. Multi-byte safe:\n(0x0A) does not appear in UTF-8 continuation bytes.#1455
Summary by CodeRabbit