After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 320360 - speed up iter_forward_to_end
speed up iter_forward_to_end
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-11-01 00:16 UTC by Paolo Borelli
Modified: 2005-11-02 05:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bench.c (1.33 KB, text/plain)
2005-11-01 00:17 UTC, Paolo Borelli
  Details
sysprof profile screenie (85.57 KB, image/png)
2005-11-01 00:19 UTC, Paolo Borelli
  Details
first simple patch (1.12 KB, patch)
2005-11-01 00:25 UTC, Paolo Borelli
none Details | Review
patch (2.00 KB, patch)
2005-11-01 09:27 UTC, Paolo Borelli
none Details | Review

Description Paolo Borelli 2005-11-01 00:16:42 UTC
gtk_text_iter_forward_to_end shows up in some profiles, for instance in gedit's
replace all.

here is a (somewhat pathological) bench that moves an iter to end in a loop.
Comment 1 Paolo Borelli 2005-11-01 00:17:35 UTC
Created attachment 54165 [details]
bench.c

bench
Comment 2 Paolo Borelli 2005-11-01 00:19:56 UTC
Created attachment 54166 [details]
sysprof profile screenie

clearly shows the two offenders
Comment 3 Paolo Borelli 2005-11-01 00:25:22 UTC
Created attachment 54167 [details] [review]
first simple patch

This patch was simple enough and didn't require to dig into the TextView
internals. Despite its simplicity and the fact that it's a code cleanup, it
brings down gtk_text_iter_backward_char to 22%
Comment 4 Paolo Borelli 2005-11-01 09:27:13 UTC
Created attachment 54182 [details] [review]
patch

Also the other offender can be given the same treatment: this reduce the test
case (run with a 5000000 loop, by mistake I attached a version where I reduced
the loop lenght) from ~67 seconds to ~40 seconds (measured with /usr/bin/time)
Comment 5 Matthias Clasen 2005-11-02 05:18:46 UTC
2005-11-02  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtktextbtree.c (_gtk_text_line_char_to_byte_offsets): 
	* gtk/gtktextiter.c (gtk_text_iter_backward_chars): Replace
	manual offset calculations by g_utf8_offset_to_pointer().
	(#320360, Paolo Borelli)