[pitivi: 13/14] Remove an avoidable loop plotting waveforms. Micro optimization that removes



commit 19198bf628498c5c3cd04390651ce4f6664e1ea3
Author: Alessandro Decina <alessandro d gmail com>
Date:   Wed Jun 24 13:40:07 2009 +0200

    Remove an avoidable loop plotting waveforms. Micro optimization that removes
    ~30ms to each _plotWaveform call.

 pitivi/ui/previewer.py |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/ui/previewer.py b/pitivi/ui/previewer.py
index 10e6f41..02dd6ec 100644
--- a/pitivi/ui/previewer.py
+++ b/pitivi/ui/previewer.py
@@ -467,16 +467,15 @@ class RandomAccessAudioPreviewer(RandomAccessPreviewer):
 
         # generate points
         cr.set_source_rgba(0, 0, 0, 1.0)
-        points = ((x * scale, hscale - (y * hscale)) for x, y in enumerate(samples))
 
-        self._plot_points(cr, 0, hscale, points)
-        cr.stroke()
-
-    def _plot_points(self, cr, x0, y0, points):
-        cr.move_to(x0, y0)
-        for x, y in points:
+        cr.move_to(0, hscale)
+        for x, y in enumerate(samples):
+            x = x * scale
+            y = hscale - (y * hscale)
             cr.line_to(x, y)
 
+        cr.stroke()
+
     def _connectSettings(self, settings):
         RandomAccessPreviewer._connectSettings(self, settings)
         self._view = settings.showWaveforms



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]