summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2019-12-29 16:52:22 -0800
committerAndy McCurdy <andy@andymccurdy.com>2019-12-29 16:52:22 -0800
commit272d3139e1c82c2d89551f87d12df7c18d938ea2 (patch)
tree297f2dad4fb666d8bf8dedc427b1bc7e335dd303 /redis/connection.py
parent9cbb48aaa31752f8d707af9b4ec8c90a48e7f8bb (diff)
downloadredis-py-272d3139e1c82c2d89551f87d12df7c18d938ea2.tar.gz
Slight optimization to command packing.
Fixed #1255
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-xredis/connection.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 926f2c7..b27bf21 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -757,15 +757,16 @@ class Connection(object):
for arg in imap(self.encoder.encode, args):
# to avoid large string mallocs, chunk the command into the
# output list if we're sending large values
- if len(buff) > buffer_cutoff or len(arg) > buffer_cutoff:
+ arg_length = len(arg)
+ if len(buff) > buffer_cutoff or arg_length > buffer_cutoff:
buff = SYM_EMPTY.join(
- (buff, SYM_DOLLAR, str(len(arg)).encode(), SYM_CRLF))
+ (buff, SYM_DOLLAR, str(arg_length).encode(), SYM_CRLF))
output.append(buff)
output.append(arg)
buff = SYM_CRLF
else:
buff = SYM_EMPTY.join(
- (buff, SYM_DOLLAR, str(len(arg)).encode(),
+ (buff, SYM_DOLLAR, str(arg_length).encode(),
SYM_CRLF, arg, SYM_CRLF))
output.append(buff)
return output