Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Two optimizations in quickch():



details:   https://anonhg.NetBSD.org/src/rev/c1c4b4ecd815
branches:  trunk
changeset: 486325:c1c4b4ecd815
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Fri May 19 04:15:55 2000 +0000

description:
Two optimizations in quickch():
* Don't bother comparing lines that are not dirty when looking for the top
  and bottom regions.
* In the loop that searches for the largest equal region, do the totally
  half-assed hack of splitting the inner loop into two parts -- comparing
  only the hash values the first time, and doing memcmp()s the second time.
  This makes many of my test cases >100x as fast.
  XXX This code needs a lot more work.

diffstat:

 lib/libcurses/refresh.c |  40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)

diffs (75 lines):

diff -r 2ba90c82a4ae -r c1c4b4ecd815 lib/libcurses/refresh.c
--- a/lib/libcurses/refresh.c   Fri May 19 04:03:33 2000 +0000
+++ b/lib/libcurses/refresh.c   Fri May 19 04:15:55 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refresh.c,v 1.31 2000/05/19 01:05:44 mycroft Exp $     */
+/*     $NetBSD: refresh.c,v 1.32 2000/05/19 04:15:55 mycroft Exp $     */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c  8.7 (Berkeley) 8/13/94";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.31 2000/05/19 01:05:44 mycroft Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.32 2000/05/19 04:15:55 mycroft Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -742,10 +742,11 @@
         */
        for (top = 0; top < __virtscr->maxy; top++)
                if (__virtscr->lines[top]->flags & __FORCEPAINT ||
-                   __virtscr->lines[top]->hash != curscr->lines[top]->hash
-                   || memcmp(__virtscr->lines[top]->line,
-                       curscr->lines[top]->line,
-                       (size_t) __virtscr->maxx * __LDATASIZE) != 0)
+                   (__virtscr->lines[top]->flags & __ISDIRTY &&
+                    (__virtscr->lines[top]->hash != curscr->lines[top]->hash
+                     || memcmp(__virtscr->lines[top]->line,
+                         curscr->lines[top]->line,
+                         (size_t) __virtscr->maxx * __LDATASIZE) != 0)))
                        break;
                else
                        __virtscr->lines[top]->flags &= ~__ISDIRTY;
@@ -754,10 +755,11 @@
         */
        for (bot = __virtscr->maxy - 1; bot >= 0; bot--)
                if (__virtscr->lines[bot]->flags & __FORCEPAINT ||
-                   __virtscr->lines[bot]->hash != curscr->lines[bot]->hash
-                   || memcmp(__virtscr->lines[bot]->line,
-                       curscr->lines[bot]->line,
-                       (size_t) __virtscr->maxx * __LDATASIZE) != 0)
+                   (__virtscr->lines[bot]->flags & __ISDIRTY &&
+                    (__virtscr->lines[bot]->hash != curscr->lines[bot]->hash
+                     || memcmp(__virtscr->lines[bot]->line,
+                         curscr->lines[bot]->line,
+                         (size_t) __virtscr->maxx * __LDATASIZE) != 0)))
                        break;
                else
                        __virtscr->lines[bot]->flags &= ~__ISDIRTY;
@@ -813,13 +815,17 @@
                                    curs < starts + bsize; curw++, curs++)
                                        if (__virtscr->lines[curw]->flags &
                                            __FORCEPAINT ||
-                                           (__virtscr->lines[curw]->hash !=
-                                               curscr->lines[curs]->hash ||
-                                               memcmp(__virtscr->lines[curw]
-                                                   ->line,
-                                                   curscr->lines[curs]->line,
-                                                   (size_t) __virtscr->maxx *
-                                                   __LDATASIZE) != 0))
+                                           __virtscr->lines[curw]->hash !=
+                                               curscr->lines[curs]->hash)
+                                               break;
+                               if (curs != starts + bsize)
+                                       continue;
+                               for (curw = startw, curs = starts;
+                                   curs < starts + bsize; curw++, curs++)
+                                       if (memcmp(__virtscr->lines[curw]->line,
+                                           curscr->lines[curs]->line,
+                                           (size_t) __virtscr->maxx *
+                                           __LDATASIZE) != 0)
                                                break;
                                if (curs == starts + bsize)
                                        goto done;



Home | Main Index | Thread Index | Old Index