From 2f818ed0fb57d98985d151781a2ce9b8683129ee Mon Sep 17 00:00:00 2001 From: BobCF Date: Fri, 9 Nov 2018 15:41:02 +0800 Subject: BaseTools: Replace the sqlite database with list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://bugzilla.tianocore.org/show_bug.cgi?id=1288 [V2] Optimize this patch so that it can be easy to review. This patch is just apply the change to original files while not create new similar files. [V1] This patch is one of build tool performance improvement series patches. This patch is going to use python list to store the parser data instead of using sqlite database. The replacement solution is as below: SQL insert: list.append() SQL select: list comprehension. for example: Select * from table where field = “something” -> [ item for item in table if item[3] == “something”] SQL update: python map function. for example: Update table set field1=newvalue where filed2 = “something”. -> map(lambda x: x[1] = newvalue, [item for item in table if item[2] == “something”]) SQL delete: list comprehension. With this change, We can save the time of interpreting SQL statement and the time of write database to file system Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey Reviewed-by: Liming Gao Reviewed-by: Jaben Carsey --- BaseTools/Source/Python/Workspace/MetaFileParser.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py') diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 6fde9e54f5..4bd52619a9 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1372,8 +1372,7 @@ class DscParser(MetaFileParser): MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR : self._ProcessError, } - self._Table = MetaFileStorage(self._RawTable.Cur, self.MetaFile, MODEL_FILE_DSC, True) - self._Table.Create() + self._Table = MetaFileStorage(self._RawTable.DB, self.MetaFile, MODEL_FILE_DSC, True) self._DirectiveStack = [] self._DirectiveEvalStack = [] self._FileWithError = self.MetaFile @@ -1632,7 +1631,7 @@ class DscParser(MetaFileParser): Owner = self._Content[self._ContentIndex - 1][8] else: Owner = self._Content[self._ContentIndex - 1][0] - IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem) + IncludedFileTable = MetaFileStorage(self._RawTable.DB, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem) Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable, Owner=Owner, From=FromItem) -- cgit v1.2.3