From: teodor Date: Fri, 11 Jul 2008 13:22:39 +0000 (+0000) Subject: Add SFSFindDataFromSavedOrSave - to fast insert partially existed strings X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=commitdiff_plain;h=49bc5b6975587c1c8f31e3bff5d420b00552af7e;hp=e03ac24a619a4da8bc8cf291c16a9956adb2cd9f;p=tedtools.git Add SFSFindDataFromSavedOrSave - to fast insert partially existed strings --- diff --git a/sfxstr.c b/sfxstr.c index 50cbab4..3eb12c4 100644 --- a/sfxstr.c +++ b/sfxstr.c @@ -149,20 +149,28 @@ SFSFindData(SFSTree *info, char *word, int len) { in.key = word; in.keylen = len; - return SFSFindDataOrSave(info, &in, NULL); + return SFSFindDataFromSavedOrSave(info, &in, NULL); } void* SFSFindDataOrSave(SFSTree *info, SFSDataIO *in, SFSTreePosition *position) { + if ( position ) + memset(position, 0, sizeof(position)); + + return SFSFindDataFromSavedOrSave(info, in, position); +} + +void* +SFSFindDataFromSavedOrSave(SFSTree *info, SFSDataIO *in, SFSTreePosition *position) { SFSNode *node = info->node; SFSNode **pnode = &(info->node); SFSNodeData *StopLow, *StopHigh, *StopMiddle; u_int8_t *ptr =(u_int8_t*)in->key; - if ( position ) { - position->nodeptr = NULL; - position->node = NULL; - position->level = 0; + if ( position && position->nodeptr && position->node && in->keylen > position->level ) { + node = position->node; + pnode = position->nodeptr; + ptr += position->level; } while( node && !ISEND(ptr, in->key, in->keylen) ) { diff --git a/sfxstr.h b/sfxstr.h index c49ac24..283326c 100644 --- a/sfxstr.h +++ b/sfxstr.h @@ -192,6 +192,7 @@ typedef struct SFSTreePosition { } SFSTreePosition; void* SFSFindDataOrSave(SFSTree *info, SFSDataIO *in, SFSTreePosition *position); +void* SFSFindDataFromSavedOrSave(SFSTree *info, SFSDataIO *in, SFSTreePosition *position); void SFSAddSaved(SFSTree *info, SFSDataIO *in, SFSTreePosition *position); /*