Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
b0168509
Commit
b0168509
authored
May 27, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_add_wordinfo() and _mass_add_wordinfo(): it's never necessary to call
len(IIBTree) in these guys, so don't.
parent
1134b4cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
lib/python/Products/ZCTextIndex/BaseIndex.py
lib/python/Products/ZCTextIndex/BaseIndex.py
+9
-4
No files found.
lib/python/Products/ZCTextIndex/BaseIndex.py
View file @
b0168509
...
...
@@ -234,7 +234,11 @@ class BaseIndex(Persistent):
else
:
# _add_wordinfo() is called for each update. If the map
# size exceeds the DICT_CUTOFF, convert to an IIBTree.
if
len
(
doc2score
)
==
self
.
DICT_CUTOFF
:
# Obscure: First check the type. If it's not a dict, it
# can't need conversion, and then we can avoid an expensive
# len(IIBTree).
if
(
isinstance
(
doc2score
,
type
({}))
and
len
(
doc2score
)
==
self
.
DICT_CUTOFF
):
doc2score
=
IIBTree
(
doc2score
)
doc2score
[
docid
]
=
f
self
.
_wordinfo
[
wid
]
=
doc2score
# not redundant: Persistency!
...
...
@@ -248,14 +252,15 @@ class BaseIndex(Persistent):
#
# except that _mass_add_wordinfo doesn't require so many function calls.
def
_mass_add_wordinfo
(
self
,
wid2weight
,
docid
):
dicttype
=
type
({})
get_doc2score
=
self
.
_wordinfo
.
get
for
wid
,
weight
in
wid2weight
.
items
():
doc2score
=
get_doc2score
(
wid
)
if
doc2score
is
None
:
doc2score
=
{}
el
se
:
if
len
(
doc2score
)
==
self
.
DICT_CUTOFF
:
doc2score
=
IIBTree
(
doc2score
)
el
if
(
isinstance
(
doc2score
,
dicttype
)
and
len
(
doc2score
)
==
self
.
DICT_CUTOFF
)
:
doc2score
=
IIBTree
(
doc2score
)
doc2score
[
docid
]
=
weight
self
.
_wordinfo
[
wid
]
=
doc2score
# not redundant: Persistency!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment