mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Optimise converter from ini to cpp // Issue #610
This commit is contained in:
@ -53,7 +53,7 @@ class InoToCPPConverter(object):
|
|||||||
prototypes.append((file_path, match.start(), match.group(1)))
|
prototypes.append((file_path, match.start(), match.group(1)))
|
||||||
return prototypes
|
return prototypes
|
||||||
|
|
||||||
def append_prototypes(self, file_path, contents, prototypes):
|
def append_prototypes(self, contents, prototypes):
|
||||||
result = []
|
result = []
|
||||||
if not prototypes:
|
if not prototypes:
|
||||||
return result
|
return result
|
||||||
@ -63,7 +63,7 @@ class InoToCPPConverter(object):
|
|||||||
result.append("%s;" % ";\n".join([p[2] for p in prototypes]))
|
result.append("%s;" % ";\n".join([p[2] for p in prototypes]))
|
||||||
result.append('#line %d "%s"' % (
|
result.append('#line %d "%s"' % (
|
||||||
contents.count("\n", 0, first_pos + len(prototypes[0][2])) + 1,
|
contents.count("\n", 0, first_pos + len(prototypes[0][2])) + 1,
|
||||||
file_path))
|
prototypes[0][0]))
|
||||||
result.append(contents[first_pos:].strip())
|
result.append(contents[first_pos:].strip())
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -90,8 +90,7 @@ class InoToCPPConverter(object):
|
|||||||
result.append('#line 1 "%s"' % file_path)
|
result.append('#line 1 "%s"' % file_path)
|
||||||
|
|
||||||
if is_first and prototypes:
|
if is_first and prototypes:
|
||||||
result += self.append_prototypes(
|
result += self.append_prototypes(contents, prototypes)
|
||||||
file_path, contents, prototypes)
|
|
||||||
else:
|
else:
|
||||||
result.append(contents)
|
result.append(contents)
|
||||||
is_first = False
|
is_first = False
|
||||||
|
Reference in New Issue
Block a user