public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 00/11] BaseTools Refactoring
@ 2018-06-20 21:08 Jaben Carsey
  2018-06-20 21:08 ` [PATCH v1 01/11] BaseTools: decorate base classes to prevent instantiation Jaben Carsey
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Jaben Carsey @ 2018-06-20 21:08 UTC (permalink / raw)
  To: edk2-devel

This patch cleans up BaseTools.
On classes that are not instantiated and are deisgned as purely base classes,
they get marked using the abstract base class to prevent instantiation.  This
prevents future errors.
Create a new shared base class to centralize some code that was identical in
multiple classes.
cleanup to pass tuples to startswith and endswith instead of calling multiple
times in a single expression.
when an statement used a fixed list or tuple change to a set to allow
hashing to speed up the operation.  if the order was important then make sure
that is a list.  creating on the fly tuples serves no purpose.
use with statements for file opening and make sure we dont over request file
privilidge.  this also seems to have cleaned up the error about the file
AutoGenTimeStamp which was causing errors previously.
lots of work to elimiate concatenating strings as this is a poor performing
operation since strings are immutable and must be completely reallocated and
moved for each concatenation.


v2: Update for concerns sent by Yonghong.

Jaben Carsey (11):
  BaseTools: decorate base classes to prevent instantiation
  BaseTools: Workspace - create a base class
  BaseTools: remove unused code
  BaseTools: remove repeated calls to startswith/endswith
  BaseTools: use set presence instead of series of equality
  BaseTools: refactor section generation
  BaseTools: refactor file opening/writing
  BaseTools: refactor to change object types
  BaseTools: refactor to stop re-allocating strings
  BaseTools: change to set for membership testing
  BaseTools: remove extra assignment

 BaseTools/Source/Python/AutoGen/AutoGen.py                      | 148 ++++++-------
 BaseTools/Source/Python/AutoGen/GenC.py                         |  75 ++++---
 BaseTools/Source/Python/AutoGen/GenDepex.py                     |  42 ++--
 BaseTools/Source/Python/AutoGen/GenMake.py                      |  43 ++--
 BaseTools/Source/Python/AutoGen/GenPcdDb.py                     |  52 ++---
 BaseTools/Source/Python/AutoGen/GenVar.py                       |   6 +-
 BaseTools/Source/Python/AutoGen/IdfClassObject.py               |  21 +-
 BaseTools/Source/Python/AutoGen/StrGather.py                    |  22 +-
 BaseTools/Source/Python/AutoGen/UniClassObject.py               |   8 +-
 BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py      |  32 ++-
 BaseTools/Source/Python/BPDG/BPDG.py                            |   2 +-
 BaseTools/Source/Python/BPDG/GenVpd.py                          |  39 ++--
 BaseTools/Source/Python/Common/DataType.py                      |  37 +++-
 BaseTools/Source/Python/Common/Expression.py                    |  68 +++---
 BaseTools/Source/Python/Common/Misc.py                          |  77 +++----
 BaseTools/Source/Python/Common/Parsing.py                       |   2 +-
 BaseTools/Source/Python/Common/RangeExpression.py               |  10 +-
 BaseTools/Source/Python/Common/StringUtils.py                   |   2 +-
 BaseTools/Source/Python/Common/TargetTxtClassObject.py          |  21 +-
 BaseTools/Source/Python/Common/ToolDefClassObject.py            |   4 +-
 BaseTools/Source/Python/Common/VariableAttributes.py            |   6 +-
 BaseTools/Source/Python/Common/VpdInfoFile.py                   |   4 +-
 BaseTools/Source/Python/CommonDataClass/CommonClass.py          |  29 +--
 BaseTools/Source/Python/CommonDataClass/DataClass.py            |  47 +---
 BaseTools/Source/Python/Ecc/Check.py                            | 123 +----------
 BaseTools/Source/Python/Ecc/CodeFragmentCollector.py            |   4 +-
 BaseTools/Source/Python/Ecc/Configuration.py                    |  10 +-
 BaseTools/Source/Python/Ecc/Database.py                         |  76 +------
 BaseTools/Source/Python/Ecc/Ecc.py                              |   4 +-
 BaseTools/Source/Python/Ecc/MetaDataParser.py                   |   4 +-
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py |  54 ++---
 BaseTools/Source/Python/Ecc/c.py                                |  42 ++--
 BaseTools/Source/Python/Eot/CodeFragmentCollector.py            |   9 +-
 BaseTools/Source/Python/Eot/EotGlobalData.py                    |  14 +-
 BaseTools/Source/Python/Eot/FileProfile.py                      |   8 +-
 BaseTools/Source/Python/Eot/Parser.py                           |   4 +-
 BaseTools/Source/Python/Eot/Report.py                           |  19 +-
 BaseTools/Source/Python/Eot/c.py                                |   2 +-
 BaseTools/Source/Python/GenFds/Capsule.py                       |  26 +--
 BaseTools/Source/Python/GenFds/CapsuleData.py                   |  11 +-
 BaseTools/Source/Python/GenFds/CompressSection.py               |  24 +-
 BaseTools/Source/Python/GenFds/DataSection.py                   |  32 +--
 BaseTools/Source/Python/GenFds/DepexSection.py                  |   8 +-
 BaseTools/Source/Python/GenFds/EfiSection.py                    | 111 +++++-----
 BaseTools/Source/Python/GenFds/FdfParser.py                     | 195 ++++++++---------
 BaseTools/Source/Python/GenFds/Ffs.py                           |  88 +++-----
 BaseTools/Source/Python/GenFds/FfsFileStatement.py              |   9 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py               |  28 +--
 BaseTools/Source/Python/GenFds/Fv.py                            | 112 ++++------
 BaseTools/Source/Python/GenFds/FvImageSection.py                |  38 ++--
 BaseTools/Source/Python/GenFds/GenFds.py                        |   8 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py          |  65 ++----
 BaseTools/Source/Python/GenFds/GuidSection.py                   |  71 +++---
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py            |  15 +-
 BaseTools/Source/Python/GenFds/OptionRom.py                     |   2 -
 BaseTools/Source/Python/GenFds/Region.py                        |  17 +-
 BaseTools/Source/Python/GenFds/Section.py                       | 231 ++++++++------------
 BaseTools/Source/Python/GenFds/UiSection.py                     |  22 +-
 BaseTools/Source/Python/GenFds/VerSection.py                    |  26 +--
 BaseTools/Source/Python/GenFds/Vtf.py                           | 108 +++------
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py    |  21 +-
 BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py          |  40 ++--
 BaseTools/Source/Python/Table/Table.py                          |   6 +-
 BaseTools/Source/Python/Table/TableDataModel.py                 |  11 +-
 BaseTools/Source/Python/Table/TableReport.py                    |  47 ++--
 BaseTools/Source/Python/TargetTool/TargetTool.py                |  97 ++++----
 BaseTools/Source/Python/Trim/Trim.py                            |  76 +++----
 BaseTools/Source/Python/Workspace/BuildClassObject.py           | 149 +++++--------
 BaseTools/Source/Python/Workspace/DecBuildData.py               |   2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py               | 119 +++++-----
 BaseTools/Source/Python/Workspace/InfBuildData.py               |  32 +--
 BaseTools/Source/Python/Workspace/MetaDataTable.py              |  10 +-
 BaseTools/Source/Python/Workspace/MetaFileCommentParser.py      |   4 +-
 BaseTools/Source/Python/Workspace/MetaFileParser.py             |  74 ++++---
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py            |  20 +-
 BaseTools/Source/Python/Workspace/WorkspaceDatabase.py          |  18 +-
 BaseTools/Source/Python/build/BuildReport.py                    | 115 +++++-----
 BaseTools/Source/Python/build/build.py                          |  50 ++---
 78 files changed, 1386 insertions(+), 1922 deletions(-)

-- 
2.16.2.windows.1



^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH v1 00/11] BaseTools refactoring
@ 2018-05-14 18:09 Jaben Carsey
  2018-05-14 18:09 ` [PATCH v1 01/11] BaseTools: decorate base classes to prevent instantiation Jaben Carsey
  0 siblings, 1 reply; 13+ messages in thread
From: Jaben Carsey @ 2018-05-14 18:09 UTC (permalink / raw)
  To: edk2-devel

This patch cleans up BaseTools.
On classes that are not instantiated and are deisgned as purely base classes,
they get marked using the abstract base class to prevent instantiation.  This
prevents future errors.
Create a new shared base class to centralize some code that was identical in
multiple classes.
cleanup to pass tuples to startswith and endswith instead of calling multiple
times in a single expression.
when an statement used a fixed list or tuple change to a set to allow
hashing to speed up the operation.  if the order was important then make sure
that is a list.  creating on the fly tuples serves no purpose.
use with statements for file opening and make sure we dont over request file
privilidge.  this also seems to have cleaned up the error about the file
AutoGenTimeStamp which was causing errors previously.
lots of work to elimiate concatenating strings as this is a poor performing
operation since strings are immutable and must be completely reallocated and
moved for each concatenation.

Jaben Carsey (11):
  BaseTools: decorate base classes to prevent instantiation
  BaseTools: Workspace - create a base class
  BaseTools: remove unused code
  BaseTools: remove repeated calls to startswith/endswith
  BaseTools: use set presence instead of series of equality
  BaseTools: refactor section generation
  BaseTools: refactor file opening/writing
  BaseTools: refactor to change object types
  BaseTools: refactor to stop re-allocating strings
  BaseTools: change to set for membership testing
  BaseTools: remove extra assignment

 BaseTools/Source/Python/AutoGen/AutoGen.py                      | 248 ++++++++++----------
 BaseTools/Source/Python/AutoGen/GenC.py                         |  75 +++---
 BaseTools/Source/Python/AutoGen/GenDepex.py                     |  42 ++--
 BaseTools/Source/Python/AutoGen/GenMake.py                      |  43 ++--
 BaseTools/Source/Python/AutoGen/GenPcdDb.py                     |  52 ++--
 BaseTools/Source/Python/AutoGen/GenVar.py                       |   6 +-
 BaseTools/Source/Python/AutoGen/IdfClassObject.py               |  21 +-
 BaseTools/Source/Python/AutoGen/StrGather.py                    |  22 +-
 BaseTools/Source/Python/AutoGen/UniClassObject.py               |   8 +-
 BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py      |  32 ++-
 BaseTools/Source/Python/BPDG/BPDG.py                            |   2 +-
 BaseTools/Source/Python/BPDG/GenVpd.py                          |  38 ++-
 BaseTools/Source/Python/Common/DataType.py                      |  37 ++-
 BaseTools/Source/Python/Common/Expression.py                    |  68 +++---
 BaseTools/Source/Python/Common/Misc.py                          |  77 +++---
 BaseTools/Source/Python/Common/Parsing.py                       |   2 +-
 BaseTools/Source/Python/Common/RangeExpression.py               |  10 +-
 BaseTools/Source/Python/Common/String.py                        |   2 +-
 BaseTools/Source/Python/Common/TargetTxtClassObject.py          |  21 +-
 BaseTools/Source/Python/Common/ToolDefClassObject.py            |   4 +-
 BaseTools/Source/Python/Common/VariableAttributes.py            |   6 +-
 BaseTools/Source/Python/Common/VpdInfoFile.py                   |   4 +-
 BaseTools/Source/Python/CommonDataClass/CommonClass.py          |  29 +--
 BaseTools/Source/Python/CommonDataClass/DataClass.py            |  47 +---
 BaseTools/Source/Python/Ecc/Check.py                            | 123 +---------
 BaseTools/Source/Python/Ecc/CodeFragmentCollector.py            |   4 +-
 BaseTools/Source/Python/Ecc/Configuration.py                    |  10 +-
 BaseTools/Source/Python/Ecc/Database.py                         |  76 +-----
 BaseTools/Source/Python/Ecc/Ecc.py                              |   4 +-
 BaseTools/Source/Python/Ecc/MetaDataParser.py                   |   4 +-
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py |  54 +++--
 BaseTools/Source/Python/Ecc/c.py                                |  42 ++--
 BaseTools/Source/Python/Eot/CodeFragmentCollector.py            |   9 +-
 BaseTools/Source/Python/Eot/EotGlobalData.py                    |  14 +-
 BaseTools/Source/Python/Eot/FileProfile.py                      |   8 +-
 BaseTools/Source/Python/Eot/Parser.py                           |   4 +-
 BaseTools/Source/Python/Eot/Report.py                           |  19 +-
 BaseTools/Source/Python/Eot/c.py                                |   2 +-
 BaseTools/Source/Python/GenFds/Capsule.py                       |  26 +-
 BaseTools/Source/Python/GenFds/CapsuleData.py                   |  11 +-
 BaseTools/Source/Python/GenFds/CompressSection.py               |  24 +-
 BaseTools/Source/Python/GenFds/DataSection.py                   |  32 +--
 BaseTools/Source/Python/GenFds/DepexSection.py                  |   8 +-
 BaseTools/Source/Python/GenFds/EfiSection.py                    | 111 ++++-----
 BaseTools/Source/Python/GenFds/FdfParser.py                     | 195 ++++++++-------
 BaseTools/Source/Python/GenFds/Ffs.py                           |  88 +++----
 BaseTools/Source/Python/GenFds/FfsFileStatement.py              |   9 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py               |  28 +--
 BaseTools/Source/Python/GenFds/Fv.py                            | 112 +++------
 BaseTools/Source/Python/GenFds/FvImageSection.py                |  38 ++-
 BaseTools/Source/Python/GenFds/GenFds.py                        |   8 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py          |  65 ++---
 BaseTools/Source/Python/GenFds/GuidSection.py                   |  71 +++---
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py            |  15 +-
 BaseTools/Source/Python/GenFds/OptionRom.py                     |   2 -
 BaseTools/Source/Python/GenFds/Region.py                        |  17 +-
 BaseTools/Source/Python/GenFds/Section.py                       | 231 ++++++++----------
 BaseTools/Source/Python/GenFds/UiSection.py                     |  22 +-
 BaseTools/Source/Python/GenFds/VerSection.py                    |  26 +-
 BaseTools/Source/Python/GenFds/Vtf.py                           | 108 +++------
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py    |  21 +-
 BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py          |  39 +--
 BaseTools/Source/Python/Table/Table.py                          |   6 +-
 BaseTools/Source/Python/Table/TableDataModel.py                 |  11 +-
 BaseTools/Source/Python/Table/TableReport.py                    |  47 ++--
 BaseTools/Source/Python/TargetTool/TargetTool.py                |  97 ++++----
 BaseTools/Source/Python/Trim/Trim.py                            |  76 +++---
 BaseTools/Source/Python/Workspace/BuildClassObject.py           | 149 +++++-------
 BaseTools/Source/Python/Workspace/DecBuildData.py               |   2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py               | 119 +++++-----
 BaseTools/Source/Python/Workspace/InfBuildData.py               |  32 +--
 BaseTools/Source/Python/Workspace/MetaDataTable.py              |  10 +-
 BaseTools/Source/Python/Workspace/MetaFileCommentParser.py      |   4 +-
 BaseTools/Source/Python/Workspace/MetaFileParser.py             |  74 +++---
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py            |  20 +-
 BaseTools/Source/Python/Workspace/WorkspaceDatabase.py          |  18 +-
 BaseTools/Source/Python/build/BuildReport.py                    | 115 +++++----
 BaseTools/Source/Python/build/build.py                          | 140 ++++++-----
 78 files changed, 1478 insertions(+), 2018 deletions(-)

-- 
2.16.2.windows.1



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-06-20 21:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-20 21:08 [PATCH v2 00/11] BaseTools Refactoring Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 01/11] BaseTools: decorate base classes to prevent instantiation Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 02/11] BaseTools: Workspace - create a base class Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 03/11] BaseTools: remove unused code Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 04/11] BaseTools: remove repeated calls to startswith/endswith Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 05/11] BaseTools: use set presence instead of series of equality Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 06/11] BaseTools: refactor section generation Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 07/11] BaseTools: refactor file opening/writing Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 08/11] BaseTools: refactor to change object types Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 09/11] BaseTools: refactor to stop re-allocating strings Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 10/11] BaseTools: change to set for membership testing Jaben Carsey
2018-06-20 21:08 ` [PATCH v1 11/11] BaseTools: remove extra assignment Jaben Carsey
  -- strict thread matches above, loose matches on Subject: below --
2018-05-14 18:09 [PATCH v1 00/11] BaseTools refactoring Jaben Carsey
2018-05-14 18:09 ` [PATCH v1 01/11] BaseTools: decorate base classes to prevent instantiation Jaben Carsey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox