[patch] reduce malloc/free use a bit
Hi, the patch below reduces the use of malloc/free a bit. For loading http://www.w3.org/TR/xslt for example it reduces the number of calls to dMalloc() from 76735 to 50478 (according to gprof). I have removed the SPCBuf member of html, as it seems not to be used. Please correct me if I'm wrong or it is intended to be used for in the future. Cheers, Johannes diff --git a/src/html.cc b/src/html.cc --- a/src/html.cc +++ b/src/html.cc @@ -295,8 +295,6 @@ public: //BUG: for now everything is pu Dstr *Stash; bool_t StashSpace; - - char *SPCBuf; /* Buffer for white space */ int pre_column; /* current column, used in PRE tags with tabs */ bool_t PreFirstChar; /* used to skip the first CR or CRLF in PRE tags */ @@ -823,8 +821,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw Stash = dStr_new(""); StashSpace = FALSE; - SPCBuf = NULL; - pre_column = 0; PreFirstChar = FALSE; PrevWasCR = FALSE; @@ -1011,7 +1007,6 @@ void DilloHtml::closeParser(int ClientKe delete (stack); dStr_free(Stash, TRUE); - dFree(SPCBuf); dStr_free(attr_data, TRUE); /* Fit the UTF-8 buffer */ @@ -1430,9 +1425,7 @@ static void Html_process_space(DilloHtml html->SPCPending = FALSE; } else if (parse_mode == DILLO_HTML_PARSE_MODE_VERBATIM) { - char *Pword = dStrndup(space, spacesize); - dStr_append(html->Stash, Pword); - dFree(Pword); + dStr_append_l(html->Stash, space, spacesize); html->SPCPending = FALSE; } else if (parse_mode == DILLO_HTML_PARSE_MODE_PRE) { @@ -1475,8 +1468,6 @@ static void Html_process_space(DilloHtml /* SGML_SPCDEL ignores white space inmediately after an open tag */ html->SPCPending = FALSE; } else { - dFree(html->SPCBuf); - html->SPCBuf = dStrndup(space, spacesize); html->SPCPending = TRUE; } @@ -1510,9 +1501,7 @@ static void Html_process_word(DilloHtml } else if (parse_mode == DILLO_HTML_PARSE_MODE_VERBATIM) { /* word goes in untouched, it is not processed here. */ - Pword = dStrndup(word, size); - dStr_append(html->Stash, Pword); - dFree(Pword); + dStr_append_l(html->Stash, word, size); } if (parse_mode == DILLO_HTML_PARSE_MODE_STASH ||
On Wed, Mar 12, 2008 at 09:26:52PM +0100, Johannes Hofmann wrote:
Hi,
the patch below reduces the use of malloc/free a bit. For loading http://www.w3.org/TR/xslt for example it reduces the number of calls to dMalloc() from 76735 to 50478 (according to gprof).
I have removed the SPCBuf member of html, as it seems not to be used. Please correct me if I'm wrong or it is intended to be used for in the future.
Committed. It may remain from the old way of handling whitespace... -- Cheers Jorge.-
participants (2)
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de