Alecf:
Given the current processor designs, not to mention the overhead of
Python, I would be very surprised if you see benefit from moving a
float to an int. Did you measure any perfromance improvement from that
change?
John
[email protected] wrote:
- Revision
- 7659
- Author
- alecf
- Date
- 2005-10-06 11:44:06 -0700 (Thu, 06 Oct 2005)
Log Message
more optimization in calendar drawing:
- calculate the locale-specific hour strings for the legend once,
rather than on every paint
- use Freeze/Thaw on the header while changing the widths of all the
columns
- round the 255-based colors to integers early, so that folks dealing
with rgb2color results are not bogged down with floats
Modified Paths
Diff
Modified:
trunk/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py (7658
=> 7659)
--- trunk/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py 2005-10-06 17:44:23 UTC (rev 7658)
+++ trunk/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py 2005-10-06 18:44:06 UTC (rev 7659)
@@ -12,7 +12,7 @@
return red/255.0, green/255.0, blue/255.0
def rgb2color(r, g, b):
- return r*255, g*255, b*255
+ return int(r*255), int(g*255), int(b*255)
def SetTextColorsAndFont(grid, attr, dc, isSelected):
"""
Modified:
trunk/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py
(7658 => 7659)
--- trunk/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py 2005-10-06 17:44:23 UTC (rev 7658)
+++ trunk/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py 2005-10-06 18:44:06 UTC (rev 7659)
@@ -1,4 +1,4 @@
-"""
+""
Canvas for calendaring blocks
"""
@@ -603,7 +603,7 @@
if item in collections:
widget.Refresh()
-
+
def onSelectWeekEvent(self, event):
self.dayMode = not event.arguments['doSelectWeek']
if self.dayMode:
@@ -769,7 +769,6 @@
else:
date = date.astimezone(defaultTzinfo)
- defaultTzinfo = ICUtzinfo.getDefault()
if nextDate.tzinfo is None:
nextDate = nextDate.replace(tzinfo=defaultTzinfo)
else:
@@ -1294,7 +1293,7 @@
def onSelectedDateChangedEvent(self, event):
super(CalendarControl, self).onSelectedDateChangedEvent(event)
-
+
def onSelectWeekEvent(self, event):
"""
I believe, as of now only calctrl sends SelectWeek events anyways.. but just in case...
@@ -1466,8 +1465,10 @@
def ResizeHeader(self):
drawInfo = self
+ self.weekColumnHeader.Freeze()
for (i,width) in enumerate(drawInfo.columnWidths):
self.weekColumnHeader.SetUIExtent(i, (0,width))
+ self.weekColumnHeader.Thaw()
def OnSize(self, event):
self._doDrawingCalculations()
Modified:
trunk/chandler/parcels/osaf/framework/blocks/calendar/TimedCanvas.py
(7658 => 7659)
--- trunk/chandler/parcels/osaf/framework/blocks/calendar/TimedCanvas.py 2005-10-06 17:44:23 UTC (rev 7658)
+++ trunk/chandler/parcels/osaf/framework/blocks/calendar/TimedCanvas.py 2005-10-06 18:44:06 UTC (rev 7659)
@@ -61,7 +61,6 @@
self.Refresh()
event.Skip()
-
def OnInit(self):
super (wxTimedEventsCanvas, self).OnInit()
@@ -71,6 +70,8 @@
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)
+ self.localeHourStrings = list(self.GetLocaleHourStrings(range(24)))
+
def ScaledScroll(self, dx, dy):
(scrollX, scrollY) = self.CalcUnscrolledPosition(0,0)
scrollX += dx
@@ -114,10 +115,9 @@
timeFormatter = DateFormat.createTimeInstance()
hourFP = FieldPosition(DateFormat.HOUR1_FIELD)
dummyDate = date.today()
- defaultTzinfo = TimeZoneInfo.get(view=self.blockItem.itsView).default
-
+
for hour in hourrange:
- timedate = time(hour=hour, tzinfo=defaultTzinfo)
+ timedate = time(hour=hour)
hourdate = datetime.combine(dummyDate, timedate)
timeString = timeFormatter.format(hourdate, hourFP)
(start, end) = (hourFP.getBeginIndex(),hourFP.getEndIndex())
@@ -146,7 +146,7 @@
halfHourHeight = self.hourHeight/2
# we'll need these for hour formatting
- for hour,hourString in self.GetLocaleHourStrings(range(24)):
+ for hour,hourString in self.localeHourStrings:
if hour > 0:
# Draw the hour legend
@@ -194,7 +194,7 @@
rects = \
TimedCanvasItem.GenerateBoundsRects(self,
self._bgSelectionStartTime,
- self._bgSelectionEndTime,
+ self._bgSelectionEndTime,
self.dayWidth)
for rect in rects:
dc.DrawRectangleRect(rect)
@@ -263,7 +263,7 @@
# sorted by startTime. If no conflicts, this is an O(n) operation
# (note that as of Python 2.4, sorts are stable, so this remains safe)
self.canvasItemList.sort(key=TimedCanvasItem.GetIndentLevel)
-
+
def DrawCells(self, dc):
styles = self.blockItem.calendarContainer
_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits
|