BaseTools/TianoCompress: Improve performance of boundary validation

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Shenglei Zhang 2019-02-25 13:37:56 +08:00 committed by Liming Gao
parent a068102296
commit f67786e381
1 changed files with 4 additions and 3 deletions

View File

@ -2281,10 +2281,11 @@ Returns:
if (Len <= TableBits) {
for (Index = Start[Len]; Index < NextCode; Index++) {
if (Index >= MaxTableLength) {
if (Start[Len] >= NextCode || NextCode > MaxTableLength){
return (UINT16) BAD_TABLE;
}
for (Index = Start[Len]; Index < NextCode; Index++) {
Table[Index] = Char;
}