[pywin32-checkins] pywin32/win32/Lib win32gui_struct.py,1.6,1.7
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-04-12 03:32:57
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4086/lib Modified Files: win32gui_struct.py Log Message: Optimize PackLVITEM by 'inlining' _GetMaskAndVal Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32gui_struct.py 20 Jan 2005 06:49:08 -0000 1.6 --- win32gui_struct.py 12 Apr 2005 03:32:44 -0000 1.7 *************** *** 242,245 **** --- 242,249 ---- # Helpers for the ugly win32 structure packing/unpacking + # XXX - Note that functions using _GetMaskAndVal run 3x faster if they are + # 'inlined' into the function - see PackLVITEM. If the profiler points at + # _GetMaskAndVal(), you should nuke it (patches welcome once they have been + # tested) def _GetMaskAndVal(val, default, mask, flag): if val is None: *************** *** 351,369 **** extra = [] # objects we must keep references to mask = 0 ! mask, item = _GetMaskAndVal(item, 0, mask, None) ! mask, subItem = _GetMaskAndVal(subItem, 0, mask, None) ! mask, state = _GetMaskAndVal(state, 0, mask, commctrl.LVIF_STATE) ! if not mask & commctrl.LVIF_STATE: stateMask = 0 else: ! if stateMask is None: ! stateMask = state ! mask, text = _GetMaskAndVal(text, None, mask, commctrl.LVIF_TEXT) ! mask, image = _GetMaskAndVal(image, 0, mask, commctrl.LVIF_IMAGE) ! mask, param = _GetMaskAndVal(param, 0, mask, commctrl.LVIF_PARAM) ! mask, indent = _GetMaskAndVal(indent, 0, mask, commctrl.LVIF_INDENT) if text is None: text_addr = text_len = 0 else: if isinstance(text, unicode): text = text.encode("mbcs") --- 355,379 ---- extra = [] # objects we must keep references to mask = 0 ! # _GetMaskAndVal adds quite a bit of overhead to this function. ! if item is None: item = 0 # No mask for item ! if subItem is None: subItem = 0 # No mask for sibItem ! if state is None: ! state = 0 stateMask = 0 else: ! mask |= commctrl.LVIF_STATE ! if stateMask is None: stateMask = state ! ! if image is None: image = 0 ! else: mask |= commctrl.LVIF_IMAGE ! if param is None: param = 0 ! else: mask |= commctrl.LVIF_PARAM ! if indent is None: indent = 0 ! else: mask |= commctrl.LVIF_INDENT ! if text is None: text_addr = text_len = 0 else: + mask |= commctrl.LVIF_TEXT if isinstance(text, unicode): text = text.encode("mbcs") |