user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] http: simplify offset calculation slightly
@ 2016-02-27  2:14 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-02-27  2:14 UTC (permalink / raw)
  To: meta

No point in comparing an empty string; length() is only
potentially expensive on big strings.
---
 lib/PublicInbox/HTTP.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index f65deda..f1016d2 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -40,7 +40,7 @@ sub event_read { # called by Danga::Socket
 
 	return event_read_input($self) if defined $self->{env};
 
-	my $off = $self->{rbuf} eq '' ? 0 : length($self->{rbuf});
+	my $off = length($self->{rbuf});
 	my $r = sysread($self->{sock}, $self->{rbuf}, 8192, $off);
 	if (defined $r) {
 		return $self->close if $r == 0;
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-02-27  2:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-27  2:14 [PATCH] http: simplify offset calculation slightly 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).