diff options
author | Carsey, Jaben <jaben.carsey@intel.com> | 2018-04-28 06:32:37 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-05-04 13:03:08 +0800 |
commit | 64bb8d4d51ec72051fffa96ddc91178fb6b33288 (patch) | |
tree | 7e64496e843da35d363211bc20cbdb99126dd548 | |
parent | 61f5b77dd5eefe5e92ba89281e95037c8d457a72 (diff) | |
download | edk2-64bb8d4d51ec72051fffa96ddc91178fb6b33288.tar.gz edk2-64bb8d4d51ec72051fffa96ddc91178fb6b33288.tar.bz2 edk2-64bb8d4d51ec72051fffa96ddc91178fb6b33288.zip |
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>
-rw-r--r-- | BaseTools/Source/Python/AutoGen/GenPcdDb.py | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index f8fbd06f5c..d237178c83 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -282,13 +282,9 @@ def toHex(s): #
class DbItemList:
def __init__(self, ItemSize, DataList=None, RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
self.ItemSize = ItemSize
- self.DataList = DataList
- self.RawDataList = RawDataList
+ self.DataList = DataList if DataList else []
+ self.RawDataList = RawDataList if RawDataList else []
self.ListSize = 0
def GetInterOffset(self, Index):
@@ -357,11 +353,8 @@ class DbItemList: #
class DbExMapTblItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+
def PackData(self):
Buffer = ''
PackStr = "=LHH"
@@ -379,11 +372,8 @@ class DbExMapTblItemList (DbItemList): #
class DbComItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+
def GetInterOffset(self, Index):
Offset = 0
if self.ItemSize == 0:
@@ -443,11 +433,8 @@ class DbComItemList (DbItemList): #
class DbVariableTableItemList (DbComItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
DbComItemList.__init__(self, ItemSize, DataList, RawDataList)
+
def PackData(self):
PackStr = "=LLHHLHH"
Buffer = ''
@@ -465,10 +452,6 @@ class DbVariableTableItemList (DbComItemList): class DbStringHeadTableItemList(DbItemList):
def __init__(self,ItemSize,DataList=None,RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList)
def GetInterOffset(self, Index):
@@ -511,11 +494,8 @@ class DbStringHeadTableItemList(DbItemList): #
class DbSkuHeadTableItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+
def PackData(self):
PackStr = "=LL"
Buffer = ''
@@ -531,11 +511,8 @@ class DbSkuHeadTableItemList (DbItemList): #
class DbSizeTableItemList (DbItemList):
def __init__(self, ItemSize, DataList=None, RawDataList=None):
- if DataList is None:
- DataList = []
- if RawDataList is None:
- RawDataList = []
DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+
def GetListSize(self):
length = 0
for Data in self.RawDataList:
|