Skip to content

Commit 6da1add

Browse files
Move the args.split() call up a level to reduce memory usage.
1 parent e0d9f3d commit 6da1add

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

adafruit_gps.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def update(self):
265265
return True
266266

267267
result = True
268+
args = args.split(",")
268269
if sentence_type == b"GLL": # Geographic position - Latitude/Longitude
269270
result = self._parse_gll(args)
270271
elif sentence_type == b"RMC": # Minimum location info
@@ -406,10 +407,9 @@ def _update_timestamp_utc(self, time_utc, date=None):
406407
(year, month, day, hours, mins, secs, 0, 0, -1)
407408
)
408409

409-
def _parse_gll(self, args):
410+
def _parse_gll(self, data):
410411
# GLL - Geographic Position - Latitude/Longitude
411412

412-
data = args.split(",")
413413
if data is None or len(data) != 7:
414414
return False # Unexpected number of params.
415415
data = _parse_data(_GLL, data)
@@ -433,10 +433,9 @@ def _parse_gll(self, args):
433433

434434
return True
435435

436-
def _parse_rmc(self, args):
436+
def _parse_rmc(self, data):
437437
# RMC - Recommended Minimum Navigation Information
438438

439-
data = args.split(",")
440439
if data is None or len(data) != 12:
441440
return False # Unexpected number of params.
442441
data = _parse_data(_RMC, data)
@@ -477,10 +476,9 @@ def _parse_rmc(self, args):
477476

478477
return True
479478

480-
def _parse_gga(self, args):
479+
def _parse_gga(self, data):
481480
# GGA - Global Positioning System Fix Data
482481

483-
data = args.split(",")
484482
if data is None or len(data) != 14:
485483
return False # Unexpected number of params.
486484
data = _parse_data(_GGA, data)
@@ -527,10 +525,9 @@ def _parse_gga(self, args):
527525

528526
return True
529527

530-
def _parse_gsa(self, talker, args):
528+
def _parse_gsa(self, talker, data):
531529
# GSA - GPS DOP and active satellites
532530

533-
data = args.split(",")
534531
if data is None or len(data) not in (17, 18):
535532
return False # Unexpected number of params.
536533
if len(data) == 17:
@@ -566,11 +563,10 @@ def _parse_gsa(self, talker, args):
566563

567564
return True
568565

569-
def _parse_gsv(self, talker, args):
566+
def _parse_gsv(self, talker, data):
570567
# GSV - Satellites in view
571568
# pylint: disable=too-many-branches
572569

573-
data = args.split(",")
574570
if data is None or len(data) not in (7, 11, 15, 19):
575571
return False # Unexpected number of params.
576572
data = _parse_data(

0 commit comments

Comments
 (0)