renamed QSE_AWK_EXTRAKWS to QSE_AWK_NEXTOFILE

fixed a minor glitch in qse_pio_t
fixed the nil field to xnil in qse_rbt_t to minimize collision with external header files since nil is a commonly found macro
added a simple optimization to qse_memcpy()
This commit is contained in:
2013-01-29 03:43:32 +00:00
parent c7d88c455a
commit 543376b7d9
11 changed files with 107 additions and 37 deletions

View File

@ -84,6 +84,25 @@ void* qse_memcpy (void* dst, const void* src, qse_size_t n)
qse_byte_t* d;
qse_byte_t* s;
if (n < 8)
{
d = (qse_byte_t*)dst;
s = (qse_byte_t*)src;
switch (n)
{
case 7: *d++ = *s++;
case 6: *d++ = *s++;
case 5: *d++ = *s++;
case 4: *d++ = *s++;
case 3: *d++ = *s++;
case 2: *d++ = *s++;
case 1: *d++ = *s++;
}
return dst;
}
if (n >= QSE_SIZEOF(qse_size_t) && IS_BOTH_ALIGNED(dst,src))
{
qse_size_t* du = (qse_size_t*)dst;

View File

@ -1264,7 +1264,7 @@ create_process:
if (!(flags & QSE_PIO_NOCLOEXEC))
{
int fd = get_highest_fd ();
while (--fd > 2)
while (fd > 2)
{
if (fd == handle[0] || fd == handle[1] ||
fd == handle[2] || fd == handle[3] ||
@ -1280,6 +1280,7 @@ create_process:
pio->errnum = syserr_to_errnum (pserr);
goto oops;
}
fd--;
}
}
@ -1419,7 +1420,7 @@ create_process:
/* close all other unknown open handles except
* stdin/out/err and the pipes. */
while (--fd > 2)
while (fd > 2)
{
if (fd != handle[0] && fd != handle[1] &&
fd != handle[2] && fd != handle[3] &&
@ -1427,6 +1428,7 @@ create_process:
{
QSE_SYSCALL1 (dummy, SYS_close, fd);
}
fd--;
}
}
@ -1610,7 +1612,7 @@ create_process:
/* close all other unknown open handles except
* stdin/out/err and the pipes. */
while (--fd > 2)
while (fd > 2)
{
if (fd != handle[0] && fd != handle[1] &&
fd != handle[2] && fd != handle[3] &&
@ -1618,6 +1620,7 @@ create_process:
{
QSE_CLOSE (fd);
}
fd--;
}
}

View File

@ -51,7 +51,7 @@
#define ENSERT 3
#define INSERT 4
#define IS_NIL(rbt,x) ((x) == &((rbt)->nil))
#define IS_NIL(rbt,x) ((x) == &((rbt)->xnil))
#define LEFT 0
#define RIGHT 1
#define left child[LEFT]
@ -76,8 +76,8 @@ QSE_INLINE pair_t* qse_rbt_allocpair (
n->color = QSE_RBT_RED;
n->parent = QSE_NULL;
n->child[LEFT] = &rbt->nil;
n->child[RIGHT] = &rbt->nil;
n->child[LEFT] = &rbt->xnil;
n->child[RIGHT] = &rbt->xnil;
KLEN(n) = klen;
if (kcop == QSE_RBT_COPIER_SIMPLE)
@ -231,13 +231,13 @@ int qse_rbt_init (rbt_t* rbt, mmgr_t* mmgr, int kscale, int vscale)
rbt->mancbs = &mancbs[0];
/* self-initializing nil */
QSE_MEMSET(&rbt->nil, 0, QSE_SIZEOF(rbt->nil));
rbt->nil.color = QSE_RBT_BLACK;
rbt->nil.left = &rbt->nil;
rbt->nil.right = &rbt->nil;
QSE_MEMSET(&rbt->xnil, 0, QSE_SIZEOF(rbt->xnil));
rbt->xnil.color = QSE_RBT_BLACK;
rbt->xnil.left = &rbt->xnil;
rbt->xnil.right = &rbt->xnil;
/* root is set to nil initially */
rbt->root = &rbt->nil;
rbt->root = &rbt->xnil;
return 0;
}
@ -546,7 +546,7 @@ static pair_t* insert (
if (x_par == QSE_NULL)
{
/* the tree contains no pair */
QSE_ASSERT (rbt->root == &rbt->nil);
QSE_ASSERT (rbt->root == &rbt->xnil);
rbt->root = x_new;
}
else
@ -555,12 +555,12 @@ static pair_t* insert (
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
if (n > 0)
{
QSE_ASSERT (x_par->right == &rbt->nil);
QSE_ASSERT (x_par->right == &rbt->xnil);
x_par->right = x_new;
}
else
{
QSE_ASSERT (x_par->left == &rbt->nil);
QSE_ASSERT (x_par->left == &rbt->xnil);
x_par->left = x_new;
}
@ -666,7 +666,7 @@ pair_t* qse_rbt_cbsert (
if (x_par == QSE_NULL)
{
/* the tree contains no pair */
QSE_ASSERT (rbt->root == &rbt->nil);
QSE_ASSERT (rbt->root == &rbt->xnil);
rbt->root = x_new;
}
else
@ -675,12 +675,12 @@ pair_t* qse_rbt_cbsert (
int n = rbt->mancbs->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
if (n > 0)
{
QSE_ASSERT (x_par->right == &rbt->nil);
QSE_ASSERT (x_par->right == &rbt->xnil);
x_par->right = x_new;
}
else
{
QSE_ASSERT (x_par->left == &rbt->nil);
QSE_ASSERT (x_par->left == &rbt->xnil);
x_par->left = x_new;
}