getLinkValue() use dbInitEntryFromAddr()

Called from dbGet().  Optimize hash table lookup
and bsearch of array to O(0) assignment.
This commit is contained in:
Michael Davidsaver
2020-05-12 08:51:51 -07:00
parent 5917990908
commit d6f8e9038c

View File

@@ -796,15 +796,12 @@ int dbLoadRecords(const char* file, const char* subs)
static long getLinkValue(DBADDR *paddr, short dbrType,
char *pbuf, long *nRequest)
{
dbCommon *precord = paddr->precord;
dbFldDes *pfldDes = paddr->pfldDes;
/* size of pbuf storage in bytes, including space for trailing nil */
int maxlen;
DBENTRY dbEntry;
long status;
long nReq = nRequest ? *nRequest : 1;
/* dbFindRecord() below will always succeed as we have a
/* below will always succeed as we have a
* valid DBADDR, so no point to check again.
* Request for zero elements always succeeds
*/
@@ -830,10 +827,8 @@ static long getLinkValue(DBADDR *paddr, short dbrType,
return S_db_badDbrtype;
}
dbInitEntry(pdbbase, &dbEntry);
status = dbFindRecord(&dbEntry, precord->name);
if (!status) status = dbFindField(&dbEntry, pfldDes->name);
if (!status) {
dbInitEntryFromAddr(paddr, &dbEntry);
{
const char *rtnString = dbGetString(&dbEntry);
strncpy(pbuf, rtnString, maxlen-1);
@@ -843,7 +838,7 @@ static long getLinkValue(DBADDR *paddr, short dbrType,
if(nRequest) *nRequest = nReq;
}
dbFinishEntry(&dbEntry);
return status;
return 0;
}
static long getAttrValue(DBADDR *paddr, short dbrType,