From 221f67d8fe77ecae6c8e99db767eace5da0c1f9e Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Thu, 3 Dec 2015 09:42:45 +0800 Subject: Move the coordinate matching to the beginning since most of the items are coordinates. For large files, this decreases total time by 10-20% --- gerber/rs274x.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'gerber') diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 96bd136..3e262b3 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -258,6 +258,14 @@ class GerberParser(object): did_something = True # make sure we do at least one loop while did_something and len(line) > 0: did_something = False + + # coord + (coord, r) = _match_one(self.COORD_STMT, line) + if coord: + yield CoordStmt.from_dict(coord, self.settings) + line = r + did_something = True + continue # Region Mode (mode, r) = _match_one(self.REGION_MODE_STMT, line) @@ -275,19 +283,10 @@ class GerberParser(object): did_something = True continue - # coord - (coord, r) = _match_one(self.COORD_STMT, line) - if coord: - yield CoordStmt.from_dict(coord, self.settings) - line = r - did_something = True - continue - # aperture selection (aperture, r) = _match_one(self.APERTURE_STMT, line) if aperture: yield ApertureStmt(**aperture) - did_something = True line = r continue -- cgit