summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/singlevalfields.py
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-09-15 08:49:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-09-15 08:51:14 +0200
commitc3c4ae5fdac0341f01eeed8d5c633d203eed8b2a (patch)
tree8fee07cdabdb5fb8e1597a88983c79bd8512ae3c /compilerplugins/clang/singlevalfields.py
parent6df2c90c08b67b943022286e7152b51d52e0ef5e (diff)
use split() to simplify loplugin python code
Change-Id: Ib6d7acf54ca6c12a3b096435f8a621244df88b4f
Diffstat (limited to 'compilerplugins/clang/singlevalfields.py')
-rwxr-xr-xcompilerplugins/clang/singlevalfields.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/compilerplugins/clang/singlevalfields.py b/compilerplugins/clang/singlevalfields.py
index f3d9c70a77e3..47c4c0d806c1 100755
--- a/compilerplugins/clang/singlevalfields.py
+++ b/compilerplugins/clang/singlevalfields.py
@@ -16,22 +16,17 @@ def normalizeTypeParams( line ):
# reading as binary (since we known it is pure ascii) is much faster than reading as unicode
with io.open("loplugin.singlevalfields.log", "rb", buffering=1024*1024) as txt:
for line in txt:
- if line.startswith("defn:\t"):
- idx1 = line.find("\t")
- idx2 = line.find("\t",idx1+1)
- idx3 = line.find("\t",idx2+1)
- parentClass = normalizeTypeParams(line[idx1+1:idx2])
- fieldName = normalizeTypeParams(line[idx2+1:idx3])
- sourceLocation = line[idx3+1:].strip()
+ tokens = line.strip().split("\t")
+ if tokens[0] == "defn:":
+ parentClass = normalizeTypeParams(tokens[1])
+ fieldName = normalizeTypeParams(tokens[2])
+ sourceLocation = tokens[3]
fieldInfo = (parentClass, fieldName)
definitionToSourceLocationMap[fieldInfo] = sourceLocation
- elif line.startswith("asgn:\t"):
- idx1 = line.find("\t")
- idx2 = line.find("\t",idx1+1)
- idx3 = line.find("\t",idx2+1)
- parentClass = normalizeTypeParams(line[idx1+1:idx2])
- fieldName = normalizeTypeParams(line[idx2+1:idx3])
- assignValue = line[idx3+1:].strip()
+ elif tokens[0] == "asgn:":
+ parentClass = normalizeTypeParams(tokens[1])
+ fieldName = normalizeTypeParams(tokens[2])
+ assignValue = tokens[3]
fieldInfo = (parentClass, fieldName)
if not fieldInfo in fieldAssignDict:
fieldAssignDict[fieldInfo] = set()