[Python-modules-commits] [python-pyld] 39/276: Made sort optimization more effective.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 8 23:47:51 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to branch master
in repository python-pyld.
commit 0369dc2a31866aa912c8b5af565ee07dbd16d63f
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Wed Nov 9 13:59:05 2011 -0500
Made sort optimization more effective.
---
lib/pyld/jsonld.py | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 7ecaaf0..4d3845a 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -988,10 +988,10 @@ class Processor:
resort = True
while len(bnodes) > 0:
if resort:
+ resort = False
bnodes.sort(cmp=bnodeSort)
# name all bnodes accoring to the first bnodes relation mappings
- # (if it has mappings then a resort will be necessary)
bnode = bnodes.pop(0)
iri = bnode['@subject']['@iri']
resort = self.serializations[iri]['props'] is not None
@@ -1020,17 +1020,17 @@ class Processor:
self.renameBlankNode(subjects[iriK], c14n.next())
renamed.append(iriK)
- # only clear serializations if resorting is necessary
- if resort:
- # only keep non-canonically named bnodes
- tmp = bnodes
- bnodes = []
- for b in tmp:
- iriB = b['@subject']['@iri']
- if not c14n.inNamespace(iriB):
- for i2 in renamed:
- self.markSerializationDirty(iriB, i2, dir)
- bnodes.append(b)
+ # only keep non-canonically named bnodes
+ tmp = bnodes
+ bnodes = []
+ for b in tmp:
+ iriB = b['@subject']['@iri']
+ if not c14n.inNamespace(iriB):
+ for i2 in renamed:
+ if self.markSerializationDirty(iriB, i2, dir):
+ # resort if a serialization was marked dirty
+ resort = True
+ bnodes.append(b)
# sort property lists that now have canonically named bnodes
for key in edges['props']:
@@ -1047,10 +1047,15 @@ class Processor:
:param iri: the IRI of the bnode to check.
:param changed: the old IRI of the bnode that changed.
:param dir: the direction to check ('props' or 'refs').
+
+ :return: True if the serialization was marked dirty, False if not.
"""
+ rval = False
s = self.serializations[iri]
if s[dir] is not None and changed in s[dir]['m']:
s[dir] = None
+ rval = True
+ return rval
def serializeMapping(self, mb):
"""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git
More information about the Python-modules-commits
mailing list