Skip to content

Commit 3fd140d

Browse files
committed
FitFile use string concat instead of format when used often
1 parent 51cd245 commit 3fd140d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fitparse/base.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _read(self, size):
7171
return data
7272

7373
def _read_struct(self, fmt, endian='<', data=None, always_tuple=False):
74-
fmt_with_endian = "%s%s" % (endian, fmt)
74+
fmt_with_endian = endian + fmt
7575
size = struct.calcsize(fmt_with_endian)
7676
if size <= 0:
7777
raise FitParseError("Invalid struct format: %s" % fmt_with_endian)
@@ -251,10 +251,7 @@ def _parse_raw_values_from_data_message(self, def_mesg):
251251
base_type = field_def.base_type
252252
is_byte = base_type.name == 'byte'
253253
# Struct to read n base types (field def size / base type size)
254-
struct_fmt = '%d%s' % (
255-
field_def.size / base_type.size,
256-
base_type.fmt,
257-
)
254+
struct_fmt = str(int(field_def.size / base_type.size)) + base_type.fmt
258255

259256
# Extract the raw value, ask for a tuple if it's a byte type
260257
raw_value = self._read_struct(

0 commit comments

Comments
 (0)