projects
/
platform
/
upstream
/
gstreamer.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e971bda
)
Replace linear-time filtered index search with usage of bisect module
author
René Stadler
<mail@renestadler.de>
Wed, 23 Jan 2008 09:03:47 +0000
(11:03 +0200)
committer
Stefan Sauer
<ensonic@users.sf.net>
Thu, 11 Sep 2014 18:51:44 +0000
(20:51 +0200)
debug-viewer/GstDebugViewer/GUI.py
patch
|
blob
|
history
diff --git
a/debug-viewer/GstDebugViewer/GUI.py
b/debug-viewer/GstDebugViewer/GUI.py
index
25059d7
..
7a45ecc
100644
(file)
--- a/
debug-viewer/GstDebugViewer/GUI.py
+++ b/
debug-viewer/GstDebugViewer/GUI.py
@@
-30,6
+30,7
@@
import os
import os.path
from operator import add
from sets import Set
import os.path
from operator import add
from sets import Set
+from bisect import bisect_right, bisect_left
import logging
import pygtk
import logging
import pygtk
@@
-564,19
+565,15
@@
class FilteredLogModel (FilteredLogModelBase):
return self.super_index[line_index]
return self.super_index[line_index]
- def __filtered_indices_in_range (self,
first, end
):
+ def __filtered_indices_in_range (self,
start, stop
):
- # FIXME: Rewrite using bisection!
-
- if first < 0:
- raise ValueError ("first cannot be negative (got %r)" % (first,))
+ if start < 0:
+ raise ValueError ("start cannot be negative (got %r)" % (start,))
- count = 0
- for i in self.super_index:
- if i >= first and i < end:
- count += 1
+ super_start = bisect_left (self.super_index, start)
+ super_stop = bisect_left (self.super_index, stop)
- return
coun
t
+ return
super_stop - super_star
t
def super_model_changed_range (self):
def super_model_changed_range (self):
@@
-1478,7
+1475,6
@@
class LineView (object):
if len (line_model):
timestamps = [row[line_model.COL_TIME] for row in line_model]
row = log_model[(line_index,)]
if len (line_model):
timestamps = [row[line_model.COL_TIME] for row in line_model]
row = log_model[(line_index,)]
- from bisect import bisect_right
position = bisect_right (timestamps, row[line_model.COL_TIME])
else:
position = 0
position = bisect_right (timestamps, row[line_model.COL_TIME])
else:
position = 0