Optimise converter from ini to cpp // Issue #610

This commit is contained in:
Ivan Kravets
2016-04-26 18:11:03 +03:00
parent 00b76e6fb5
commit 2682e8db8a

View File

@ -53,7 +53,7 @@ class InoToCPPConverter(object):
prototypes.append((file_path, match.start(), match.group(1)))
return prototypes
def append_prototypes(self, file_path, contents, prototypes):
def append_prototypes(self, contents, prototypes):
result = []
if not prototypes:
return result
@ -63,7 +63,7 @@ class InoToCPPConverter(object):
result.append("%s;" % ";\n".join([p[2] for p in prototypes]))
result.append('#line %d "%s"' % (
contents.count("\n", 0, first_pos + len(prototypes[0][2])) + 1,
file_path))
prototypes[0][0]))
result.append(contents[first_pos:].strip())
return result
@ -90,8 +90,7 @@ class InoToCPPConverter(object):
result.append('#line 1 "%s"' % file_path)
if is_first and prototypes:
result += self.append_prototypes(
file_path, contents, prototypes)
result += self.append_prototypes(contents, prototypes)
else:
result.append(contents)
is_first = False