Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_text.c Log Message: - Make _char_to_byte() and _byte_to_char() walk from the current node in the format list to the desired location instead of always starting from the beginning. This makes it ~50% faster in my test case here. There are a couple of other enhancements that could be done here, starting the search from the start/end of the list depending on index. Walking from the current position to the previous current pointer instead of from the beginning of the list. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v retrieving revision 1.140 retrieving revision 1.141 diff -u -3 -r1.140 -r1.141 --- ewl_text.c 22 Nov 2006 21:41:18 -0000 1.140 +++ ewl_text.c 22 Nov 2006 23:52:39 -0000 1.141 @@ -2584,16 +2584,37 @@ /* * Select the closest search point, first node, last node or last - * accessed node. + * accessed node. (XXX Just does current node at the moment) */ - ecore_dlist_goto_first(t->formatting.nodes); - while ((fmt = ecore_dlist_next(t->formatting.nodes))) + if (t->formatting.current.char_idx < char_idx) { - if ((char_count + fmt->char_len) > char_idx) - break; + char_count = t->formatting.current.char_idx; + bidx = t->formatting.current.byte_idx; + + /* walk forward until we cover the given position */ + fmt = ecore_dlist_current(t->formatting.nodes); + while ((fmt->char_len + char_count) < char_idx) + { + char_count += fmt->char_len; + bidx += fmt->byte_len; - char_count += fmt->char_len; - bidx += fmt->byte_len; + ecore_dlist_next(t->formatting.nodes); + fmt = ecore_dlist_current(t->formatting.nodes); + if (!fmt) break; + } + } + else + { + /* walk back until we're less then the given position */ + while (char_count > char_idx) + { + ecore_dlist_previous(t->formatting.nodes); + fmt = ecore_dlist_current(t->formatting.nodes); + if (!fmt) break; + + char_count -= fmt->char_len; + bidx -= fmt->byte_len; + } } /* we still need to count within this node */ @@ -2653,14 +2674,36 @@ DCHECK_TYPE("t", t, EWL_TEXT_TYPE); current = ecore_dlist_current(t->formatting.nodes); - ecore_dlist_goto_first(t->formatting.nodes); - while ((fmt = ecore_dlist_next(t->formatting.nodes))) + + if (t->formatting.current.byte_idx < byte_idx) { - if ((byte_count + fmt->byte_len) > byte_idx) - break; + byte_count = t->formatting.current.byte_idx; + cidx = t->formatting.current.char_idx; + + /* walk forward until we cover the given position */ + fmt = ecore_dlist_current(t->formatting.nodes); + while ((fmt->byte_len + byte_count) < byte_idx) + { + byte_count += fmt->byte_len; + cidx += fmt->char_len; + + ecore_dlist_next(t->formatting.nodes); + fmt = ecore_dlist_current(t->formatting.nodes); + if (!fmt) break; + } + } + else + { + /* walk back until we're less then the given position */ + while (byte_count > byte_idx) + { + ecore_dlist_previous(t->formatting.nodes); + fmt = ecore_dlist_current(t->formatting.nodes); + if (!fmt) break; - byte_count += fmt->byte_len; - cidx += fmt->char_len; + byte_count -= fmt->byte_len; + cidx -= fmt->char_len; + } } /* we still need to count within this node */ @@ -5173,6 +5216,7 @@ DRETURN_PTR(tx, DLEVEL_STABLE); } +#if 0 static unsigned int ewl_text_context_hash_key(void *ctx) { @@ -5222,6 +5266,7 @@ DRETURN_INT(key, DLEVEL_STABLE); } +#endif static char * ewl_text_context_name_get(Ewl_Text_Context *tx, unsigned int context_mask, ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs