[spice-common] quic: Use G_UNLIKELY in some hot paths

Submitted by Frediano Ziglio on Oct. 18, 2019, 4:08 p.m.

Details

Message ID 20191018160825.24560-1-fziglio@redhat.com
State New
Headers show
Series "quic: Use G_UNLIKELY in some hot paths" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Oct. 18, 2019, 4:08 p.m.
The buffers provided should be big enough to avoid to ask
for more space much often.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 common/quic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/common/quic.c b/common/quic.c
index e1c439f..d24a0f6 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -396,7 +396,7 @@  static void more_io_words(Encoder *encoder)
 
 static inline void write_io_word(Encoder *encoder)
 {
-    if (encoder->io_now == encoder->io_end) {
+    if (G_UNLIKELY(encoder->io_now == encoder->io_end)) {
         more_io_words(encoder);
     }
     *(encoder->io_now++) = GUINT32_TO_LE(encoder->io_word);
@@ -444,7 +444,7 @@  static inline void flush(Encoder *encoder)
 
 static inline void read_io_word(Encoder *encoder)
 {
-    if (encoder->io_now == encoder->io_end) {
+    if (G_UNLIKELY(encoder->io_now == encoder->io_end)) {
         more_io_words(encoder);
     }
     if (spice_extra_checks) {