Commit 2b4e88b
committed
perf: eliminate extra BytesIO allocation in encode_message compression path
When compression is active (protocol v4 and below), encode_message
previously created two BytesIO objects: one for the uncompressed body,
then another to write the header + compressed body. The second BytesIO
is unnecessary -- use direct bytes concatenation (header + compressed_body)
instead, which avoids one BytesIO allocation per compressed message.
The non-compression path already used a single BytesIO and is unchanged.1 parent 8e6c4d4 commit 2b4e88b
1 file changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
1101 | | - | |
1102 | 1101 | | |
1103 | 1102 | | |
1104 | 1103 | | |
1105 | | - | |
1106 | 1104 | | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1110 | 1108 | | |
1111 | 1109 | | |
1112 | 1110 | | |
1113 | 1111 | | |
1114 | 1112 | | |
1115 | | - | |
1116 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
1117 | 1116 | | |
| 1117 | + | |
| 1118 | + | |
1118 | 1119 | | |
1119 | 1120 | | |
1120 | 1121 | | |
1121 | 1122 | | |
1122 | 1123 | | |
1123 | 1124 | | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
1127 | 1128 | | |
1128 | 1129 | | |
1129 | 1130 | | |
| |||
0 commit comments