* [PATCH] nntp: use substr to check for trailing CRLF
@ 2022-07-23 6:13 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2022-07-23 6:13 UTC (permalink / raw)
To: meta
Regexps consume more CPU cycles and memory, and aren't
necessary here since we just converted the entire buffer
to CRLF.
---
lib/PublicInbox/NNTP.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 8ad7adc1..b223eb07 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -502,7 +502,7 @@ sub msg_body_write ($$) {
# these can momentarily double the memory consumption :<
$$msg =~ s/^\./../smg;
$$msg =~ s/(?<!\r)\n/\r\n/sg; # Alpine barfs without this
- $$msg .= "\r\n" unless $$msg =~ /\r\n\z/s;
+ $$msg .= "\r\n" unless substr($$msg, -2, 2) eq "\r\n";
$self->msg_more($$msg);
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-23 6:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-23 6:13 [PATCH] nntp: use substr to check for trailing CRLF Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).