summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-06-05 22:56:43 +0000
committerderaadt <deraadt@openbsd.org>1996-06-05 22:56:43 +0000
commit9459560be20ff82d43009cb6bcc09bc7308f16ca (patch)
treedb1426db482977cd9f668281b6ebcab80fc96597
parentMy ethernet is on EISA bus (diff)
downloadwireguard-openbsd-9459560be20ff82d43009cb6bcc09bc7308f16ca.tar.xz
wireguard-openbsd-9459560be20ff82d43009cb6bcc09bc7308f16ca.zip
catq() optimizations; if to queue is empty, swapping clist structures is faster
-rw-r--r--sys/kern/tty_subr.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/kern/tty_subr.c b/sys/kern/tty_subr.c
index fbef87fd854..a3398117df9 100644
--- a/sys/kern/tty_subr.c
+++ b/sys/kern/tty_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_subr.c,v 1.2 1996/03/03 17:20:12 niklas Exp $ */
+/* $OpenBSD: tty_subr.c,v 1.3 1996/06/05 22:56:43 deraadt Exp $ */
/* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */
/*
@@ -550,6 +550,21 @@ catq(from, to)
{
int c;
+ if (from->c_cc == 0) /* nothing to move */
+ return;
+
+ /*
+ * if `to' queue is empty and the queues are the same max size,
+ * it is more efficient to just swap the clist structures.
+ */
+ if (to->c_cc == 0 && from->c_cn == to->c_cn) {
+ struct clist tmp;
+
+ tmp = *from;
+ *from = *to;
+ *to = tmp;
+ }
+
while ((c = getc(from)) != -1)
putc(c, to);
}