database: Enable db.comps only when needed
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
This commit is contained in:
parent
737f7094a1
commit
4a8c99b7e5
3 changed files with 16 additions and 9 deletions
5
data.py
5
data.py
|
|
@ -174,7 +174,7 @@ class BsdDB:
|
|||
self.db.sync()
|
||||
|
||||
class DB:
|
||||
def __init__(self, dir, readonly=True):
|
||||
def __init__(self, dir, readonly=True, dtscomp=False):
|
||||
if os.path.isdir(dir):
|
||||
self.dir = dir
|
||||
else:
|
||||
|
|
@ -194,5 +194,6 @@ class DB:
|
|||
self.defs = BsdDB(dir + '/definitions.db', ro, DefList)
|
||||
self.refs = BsdDB(dir + '/references.db', ro, RefList)
|
||||
self.docs = BsdDB(dir + '/doccomments.db', ro, RefList)
|
||||
self.comps = BsdDB(dir + '/compatibledts.db', ro, RefList)
|
||||
if dtscomp:
|
||||
self.comps = BsdDB(dir + '/compatibledts.db', ro, RefList)
|
||||
# Use a RefList in case there are multiple doc comments for an identifier
|
||||
|
|
|
|||
14
query.py
14
query.py
|
|
@ -24,7 +24,9 @@ import data
|
|||
import os
|
||||
from collections import OrderedDict
|
||||
|
||||
db = data.DB(lib.getDataDir(), readonly=True)
|
||||
dts_comp_support = int(script('dts-comp'))
|
||||
|
||||
db = data.DB(lib.getDataDir(), readonly=True, dtscomp=dts_comp_support)
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
|
|
@ -181,14 +183,16 @@ def query(cmd, *args):
|
|||
elif cmd == 'dts-comp':
|
||||
# Get state of dts_comp_support
|
||||
|
||||
return script('comp-dts')
|
||||
return dts_comp_support
|
||||
|
||||
elif cmd == 'dts-comp-exists':
|
||||
# Check if a dts compatible string exists
|
||||
|
||||
ident = args[0]
|
||||
|
||||
return db.comps.exists(ident)
|
||||
if dts_comp_support:
|
||||
return db.comps.exists(ident)
|
||||
else:
|
||||
return False
|
||||
|
||||
elif cmd == 'ident':
|
||||
|
||||
|
|
@ -207,7 +211,7 @@ def query(cmd, *args):
|
|||
# Used in DT files
|
||||
# Documented in documentation files
|
||||
if family == 'B':
|
||||
if not db.comps.exists(ident):
|
||||
if not dts_comp_support or not db.comps.exists(ident):
|
||||
return symbol_definitions, symbol_references, symbol_doccomments
|
||||
|
||||
files_this_version = db.vers.get(version).iter()
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ from threading import Thread, Lock, Event, Condition
|
|||
|
||||
verbose = False
|
||||
|
||||
db = data.DB(lib.getDataDir(), readonly=False)
|
||||
dts_comp_support = int(script('dts-comp'))
|
||||
|
||||
db = data.DB(lib.getDataDir(), readonly=False, dtscomp=dts_comp_support)
|
||||
|
||||
# Number of cpu threads (+1 for version indexing)
|
||||
cpu = 8
|
||||
|
|
@ -445,7 +447,7 @@ num_th_docs = quo
|
|||
|
||||
# If DT bindings support is enabled, use $quo threads for that
|
||||
# Otherwise add them to the remaining threads
|
||||
if int(script('dts-comp')):
|
||||
if dts_comp_support:
|
||||
num_th_comps = quo
|
||||
else :
|
||||
num_th_comps = 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue