Skip to content

Commit

Permalink
src: stop search if key length provided matches record's key kength
Browse files Browse the repository at this point in the history
This saves an unneeded read, compare, etc. when updating or deleting record(s)
based on a given recordKey, since such a key must be unique.
  • Loading branch information
gabylb committed Jan 12, 2021
1 parent 09f224c commit 6e4acf4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions VsamFile.cpp
Expand Up @@ -161,6 +161,12 @@ void VsamFile::FindUpdateExecute(UvWorkData *pdata) {
if (pdata->rc_ != 0)
break;
pdata->count_++;
if (pdata->keybuf_len_ == keylen_) {
#ifdef DEBUG
fprintf(stderr,"FindUpdateExecute: key length provided is the same as the record's key length, stop search.\n");
#endif
break;
}
#ifdef DEBUG_CRUD
assert(fgetpos(stream_, &freadpos_) == 0);
#endif
Expand Down Expand Up @@ -204,6 +210,12 @@ void VsamFile::FindDeleteExecute(UvWorkData *pdata) {
if (pdata->rc_ != 0)
break;
pdata->count_++;
if (pdata->keybuf_len_ == keylen_) {
#ifdef DEBUG
fprintf(stderr,"FindDeleteExecute: key length provided is the same as the record's key length, stop search.\n");
#endif
break;
}
#ifdef DEBUG_CRUD
assert(fgetpos(stream_, &freadpos_) == 0);
#endif
Expand Down

0 comments on commit 6e4acf4

Please sign in to comment.