jerq: Here is a version of *append* that runs 3.4 times faster
Michael W. Herman
mwherman at watcgl.UUCP
Sat Apr 13 10:27:13 AEST 1985
I folded the *addbit* into *append*, added a few register variables and
*append* is running 3.4 times faster (4.2BSD on a 780). This makes *plot*
run 2 times faster.
I have also changed *plot* to output versatec format raster files that
*lpr -v* understands if anyone is interested (it's not very difficult.)
My compliments to Simon Kenyon on what seems to be an excellent package
(so far).
-------------------------- cxut here --------------------------------------
# This is a shell archive. Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file". (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# append.c
echo x - append.c
cat > "append.c" << '//E*O*F append.c//'
/*
* File: append.c
*
* Sccs-id: @(#)append.c 1.4 85/03/24
*
* Description: This file contains the one function append which
* adds some more bits to the end of the plot line.
*
* Author: Simon Kenyon.
*
* History: SCK 1.1 83/10/03 Created.
* SCK 1.2 84/11/29 Made it work.
* SCK 1.3 85/03/04 Tidied up for release.
* SCK 1.4 85/03/24 Changed the include files around.
* MWH 1.4 85/04/12 imbedded *addbit* code into *append*
*/
#include "../h/layers.h"
#define MWH850412
/*
* Name: append
*
* Description: Add some more bits to the end of the plot line.
*
* Synopsis: append (bits, start, end, size)
* unsigned short bits;
* int start;
* int end;
* int size;
*
* Called by: plot (plot.c)
*/
#ifdef MWH850412
extern int bitptr;
unsigned short line[512];
unsigned short wordmask[] = {
0x8000, 0x4000, 0x2000, 0x1000,
0x0800, 0x0400, 0x0200, 0x0100,
0x0080, 0x0040, 0x0020, 0x0010,
0x0008, 0x0004, 0x0002, 0x0001
};
append (bits, start, end, size)
register unsigned short bits;
int start;
register int end;
register int size;
{
register int i;
register int j;
register int wordidx;
register int bitidx;
wordidx = bitptr / WORDSIZE;
bitidx = bitptr % WORDSIZE;
for (i = start; i <= end; i++)
for (j = 0; j < size; j++) {
if (bits & (1 << (WORDSIZE - (i + 1))))
line[wordidx] |= wordmask[bitidx];
else
line[wordidx] &= ~wordmask[bitidx];
bitptr++;
bitidx++;
if (bitidx == WORDSIZE) {
bitidx = 0;
wordidx++;
}
}
}
#else /* original code */
append (bits, start, end, size)
register unsigned short bits;
int start;
register int end;
register int size;
{
register int i;
register int j;
for (i = start; i <= end; i++)
for (j = 0; j < size; j++)
if (bits & (1 << (WORDSIZE - (i + 1))))
addbit (1);
else
addbit (0);
}
#endif MWH850412
//E*O*F append.c//
exit 0
More information about the Comp.sources.unix
mailing list