From c57b56756a014dc331fdd5fc359d8659c408cf36 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Tue, 20 Mar 2018 06:49:01 +0000 Subject: [PATCH] apibuild: Simplify strip_lead_star() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The method strip_lead_star() removes a single leading asterisk character from a string by ignoring leading whitespace, otherwise it returns the original string. This could be achieved with a single if-statement followed by replace. Reviewed-by: Daniel P. Berrangé Signed-off-by: Radostin Stoyanov --- docs/apibuild.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 90d944ccfc..d5707d5d1c 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -721,15 +721,8 @@ class CParser: self.index.info = res def strip_lead_star(self, line): - l = len(line) - i = 0 - while i < l: - if line[i] == ' ' or line[i] == '\t': - i += 1 - elif line[i] == '*': - return line[:i] + line[i + 1:] - else: - return line + if line.lstrip().startswith('*'): + line = line.replace('*', '', 1) return line def cleanupComment(self):