]> git.proxmox.com Git - mirror_novnc.git/commit
Don't compact the receive buffer unless we've actually run out of space
authorJesper Alf Dam <jdam@vitalimages.com>
Wed, 7 Aug 2019 09:03:12 +0000 (11:03 +0200)
committerJesper Alf Dam <jdam@vitalimages.com>
Fri, 16 Aug 2019 17:34:09 +0000 (19:34 +0200)
commit7d755d10dc0a22f228d4ffced00c25f59509881e
tree6e572e94ff2ef63d1144b6de0839fea13f0774e5
parente1d50c8c10563edcacebcaeb32d022906aa003d2
Don't compact the receive buffer unless we've actually run out of space

Previously, we would compact the buffer (moving unread data to the
start of the buffer) as follows:

- after processing a message, if there are zero unread bytes, just reset
  the indices for first and last unread byte to zero
- else, if at least 1/8th of the buffer is used, copy remaining data to the beginning of the buffer

The second option is never actually necessary, as before inserting new data
into the array, we already check if there's enough free space, and
compact the buffer first if necessary. So we've been doing a lot of
copies that weren't actually needed. Let's not do that any more.
core/websock.js
tests/test.websock.js