Skip to content

Commit

Permalink
FitFile use string concat instead of format when used often
Browse files Browse the repository at this point in the history
  • Loading branch information
xmedeko committed Mar 23, 2018
1 parent 51cd245 commit 3fd140d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions fitparse/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _read(self, size):
return data

def _read_struct(self, fmt, endian='<', data=None, always_tuple=False):
fmt_with_endian = "%s%s" % (endian, fmt)
fmt_with_endian = endian + fmt
size = struct.calcsize(fmt_with_endian)
if size <= 0:
raise FitParseError("Invalid struct format: %s" % fmt_with_endian)
Expand Down Expand Up @@ -251,10 +251,7 @@ def _parse_raw_values_from_data_message(self, def_mesg):
base_type = field_def.base_type
is_byte = base_type.name == 'byte'
# Struct to read n base types (field def size / base type size)
struct_fmt = '%d%s' % (
field_def.size / base_type.size,
base_type.fmt,
)
struct_fmt = str(int(field_def.size / base_type.size)) + base_type.fmt

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

0 comments on commit 3fd140d

Please sign in to comment.