This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch main in repository pluggable-transports/snowflake-webext.
commit 38f54a2a12ac5bf255aa919eed1aa753c3e86c10 Author: WofWca wofwca@protonmail.com AuthorDate: Fri Jul 15 18:40:54 2022 +0300
perf: reorder `if` conditions
Put the one that is more likely to be `false` at the beginning --- proxypair.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/proxypair.js b/proxypair.js index 1957301..4d012d0 100644 --- a/proxypair.js +++ b/proxypair.js @@ -218,14 +218,14 @@ class ProxyPair { const checkChunks = () => { busy = false; // WebRTC --> websocket - if (this.relayIsReady() && this.relay.bufferedAmount < this.MAX_BUFFER && this.c2rSchedule.length > 0) { + if (this.c2rSchedule.length > 0 && this.relayIsReady() && this.relay.bufferedAmount < this.MAX_BUFFER) { const chunk = this.c2rSchedule.shift(); this.rateLimit.update(chunk.byteLength); this.relay.send(chunk); busy = true; } // websocket --> WebRTC - if (this.webrtcIsReady() && this.client.bufferedAmount < this.MAX_BUFFER && this.r2cSchedule.length > 0) { + if (this.r2cSchedule.length > 0 && this.webrtcIsReady() && this.client.bufferedAmount < this.MAX_BUFFER) { const chunk = this.r2cSchedule.shift(); this.rateLimit.update(chunk.byteLength); this.client.send(chunk);