From 6e4acf48d2322ecb07e7ca7375290a9278fb627d Mon Sep 17 00:00:00 2001 From: Gaby Baghdadi Date: Tue, 12 Jan 2021 17:53:25 -0500 Subject: [PATCH] src: stop search if key length provided matches record's key kength 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. --- VsamFile.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/VsamFile.cpp b/VsamFile.cpp index 291832c..f912bdd 100644 --- a/VsamFile.cpp +++ b/VsamFile.cpp @@ -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 @@ -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