BaseTools: refactor __init__ functions to not compute temporary variable

just assign correct value to member variable in __init__ or call
parent __init__

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Carsey, Jaben 2018-04-28 06:32:37 +08:00 committed by Yonghong Zhu
parent 61f5b77dd5
commit 64bb8d4d51
1 changed files with 7 additions and 30 deletions

View File

@ -282,13 +282,9 @@ def toHex(s):
# #
class DbItemList: class DbItemList:
def __init__(self, ItemSize, DataList=None, RawDataList=None): def __init__(self, ItemSize, DataList=None, RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
self.ItemSize = ItemSize self.ItemSize = ItemSize
self.DataList = DataList self.DataList = DataList if DataList else []
self.RawDataList = RawDataList self.RawDataList = RawDataList if RawDataList else []
self.ListSize = 0 self.ListSize = 0
def GetInterOffset(self, Index): def GetInterOffset(self, Index):
@ -357,11 +353,8 @@ class DbItemList:
# #
class DbExMapTblItemList (DbItemList): class DbExMapTblItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None): def __init__(self, ItemSize, DataList=None, RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList) DbItemList.__init__(self, ItemSize, DataList, RawDataList)
def PackData(self): def PackData(self):
Buffer = '' Buffer = ''
PackStr = "=LHH" PackStr = "=LHH"
@ -379,11 +372,8 @@ class DbExMapTblItemList (DbItemList):
# #
class DbComItemList (DbItemList): class DbComItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None): def __init__(self, ItemSize, DataList=None, RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList) DbItemList.__init__(self, ItemSize, DataList, RawDataList)
def GetInterOffset(self, Index): def GetInterOffset(self, Index):
Offset = 0 Offset = 0
if self.ItemSize == 0: if self.ItemSize == 0:
@ -443,11 +433,8 @@ class DbComItemList (DbItemList):
# #
class DbVariableTableItemList (DbComItemList): class DbVariableTableItemList (DbComItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None): def __init__(self, ItemSize, DataList=None, RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
DbComItemList.__init__(self, ItemSize, DataList, RawDataList) DbComItemList.__init__(self, ItemSize, DataList, RawDataList)
def PackData(self): def PackData(self):
PackStr = "=LLHHLHH" PackStr = "=LLHHLHH"
Buffer = '' Buffer = ''
@ -465,10 +452,6 @@ class DbVariableTableItemList (DbComItemList):
class DbStringHeadTableItemList(DbItemList): class DbStringHeadTableItemList(DbItemList):
def __init__(self,ItemSize,DataList=None,RawDataList=None): def __init__(self,ItemSize,DataList=None,RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList) DbItemList.__init__(self, ItemSize, DataList, RawDataList)
def GetInterOffset(self, Index): def GetInterOffset(self, Index):
@ -511,11 +494,8 @@ class DbStringHeadTableItemList(DbItemList):
# #
class DbSkuHeadTableItemList (DbItemList): class DbSkuHeadTableItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None): def __init__(self, ItemSize, DataList=None, RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList) DbItemList.__init__(self, ItemSize, DataList, RawDataList)
def PackData(self): def PackData(self):
PackStr = "=LL" PackStr = "=LL"
Buffer = '' Buffer = ''
@ -531,11 +511,8 @@ class DbSkuHeadTableItemList (DbItemList):
# #
class DbSizeTableItemList (DbItemList): class DbSizeTableItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None): def __init__(self, ItemSize, DataList=None, RawDataList=None):
if DataList is None:
DataList = []
if RawDataList is None:
RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList) DbItemList.__init__(self, ItemSize, DataList, RawDataList)
def GetListSize(self): def GetListSize(self):
length = 0 length = 0
for Data in self.RawDataList: for Data in self.RawDataList: