performace issue in Tk
From: Khamis Abuelkomboz (khamis_at_wellcode.com)
Date: 11/29/04
- Next message: Bob Techentin: "Re: autotools with tcl"
- Previous message: Mike Collins: "CSV importer ?"
- Next in thread: Benjamin Riefenstahl: "Re: performace issue in Tk"
- Reply: Benjamin Riefenstahl: "Re: performace issue in Tk"
- Reply: Donal K. Fellows: "Re: performace issue in Tk"
- Reply: Andreas Leitgeb: "Re: performace issue in Tk"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Nov 2004 22:15:50 +0100
Hi
I have found a performance and memory usage issue in the function ObjectIsEmpty implemented in
tk8.4.6\generic\tkConfig.c:2229
To test if an object is empty it just convert every object into a string. this is pretty ugly, if
you have lists in the options list. it converts all lists, integers and so on into strings. as
example, with my fix I reduced memory usage from 200MB to 110MB by large amount of data. It got even
some factors faster.
here is the origin
static int
ObjectIsEmpty(objPtr)
Tcl_Obj *objPtr; /* Object to test. May be NULL. */
{
int length;
if (objPtr == NULL) {
return 1;
}
if (objPtr->bytes != NULL) {
return (objPtr->length == 0);
}
Tcl_GetStringFromObj(objPtr, &length);
return (length == 0);
}
and the modified version
static int
ObjectIsEmpty(objPtr)
Tcl_Obj *objPtr; /* Object to test. May be NULL. */
{
int length;
if (objPtr == NULL) {
return 1;
}
if (objPtr->bytes != NULL) {
return (objPtr->length == 0);
}
++++++>>>>>>>
if (objPtr->typePtr != NULL)
{
if (stricmp(objPtr->typePtr->name, "list") == 0)
{
List *listRepPtr = (List *) objPtr->internalRep.twoPtrValue.ptr1;
int numElems = listRepPtr->elemCount;
return (numElems == 0);
}
if (stricmp(objPtr->typePtr->name, "string") != 0)
return 0;
}
++++++<<<<<<<<
Tcl_GetStringFromObj(objPtr, &length);
return (length == 0);
}
-- Try Code-Navigator on http://www.codenav.com a source code navigating, analysis and developing tool. It supports almost all languages on the scope.
- Next message: Bob Techentin: "Re: autotools with tcl"
- Previous message: Mike Collins: "CSV importer ?"
- Next in thread: Benjamin Riefenstahl: "Re: performace issue in Tk"
- Reply: Benjamin Riefenstahl: "Re: performace issue in Tk"
- Reply: Donal K. Fellows: "Re: performace issue in Tk"
- Reply: Andreas Leitgeb: "Re: performace issue in Tk"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|