generic: add usefull scripts

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-01-28 00:02:33 +02:00
parent 3339b2a6ed
commit 19a5facae5
3 changed files with 65 additions and 0 deletions

22
inlinecheck.py Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/python2
# a script to check for possible functions inlining/deinlining in headers files
import os, re
regex = re.compile('(.*[\\t| ](.*)\(\).*\{.*return.*\(\).*\})')
for root, dirs, files in os.walk(os.getcwd()):
for sfile in files:
if not sfile.endswith(('.hpp', '.h', '.hh')):
continue
sfull = '%s/%s' % (root, sfile)
with open(sfull, 'rb') as f:
content = f.read()
for match in regex.findall(content):
if 'inline' in match[0]:
print('possible removal of %s in %s' % (match[1], sfull.replace('%s/' % os.getcwd(), "")))
continue
elif 'const' in match[0] or 'virtual' in match[0]:
continue
print('possible inlining of %s in %s' % (match[1], sfull.replace('%s/' % os.getcwd(), "")))

24
qstringarg.py Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/python2
# a script to check for possible optimization of QString formatter
# if you are going to apply changes make sure you do not mix types,
# the method has several overloads!
import os, re
regex = re.compile('\.arg\(')
for root, ldirs, lfiles in os.walk(os.getcwd()):
for sfile in lfiles:
sfull = '%s/%s' % (root, sfile)
if '/.git/' in sfull:
continue
printfile = False
with open(sfull, 'r') as f:
for sline in f.readlines():
if len(regex.findall(sline)) > 1:
printfile = True
break
if printfile:
print(sfull)

19
qstringlistopti.py Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/python2
# a script to check for possible optimization of QStringList usage
import os, re
regex = re.compile('QStringList (.[^\\s|;|(]+)')
for root, dirs, files in os.walk(os.getcwd()):
for sfile in files:
if not sfile.endswith(('.hpp', '.h', '.hh', '.cpp', '.c', 'cc')):
continue
sfull = '%s/%s' % (root, sfile)
with open(sfull, 'rb') as f:
content = f.read()
for match in regex.findall(content):
if ('%s.append(' % match in content or '%s.prepend(' % match in content) \
and not '%s.reserve(' % match in content:
print('possible optimzation of %s in %s' % (match, sfull.replace('%s/' % os.getcwd(), "")))