summaryrefslogtreecommitdiff
path: root/src/Fl_Scroll.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2010-02-07 18:52:26 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2010-02-07 18:52:26 +0000
commitce7da76d6a219c5fc0a33f9c5b2701f3b47220d6 (patch)
treef27af939a2a700247d6bcccc525b9072c2a0281d /src/Fl_Scroll.cxx
parent5ec87ac84845728cc004ef2920502a8e4eb4d9a0 (diff)
Optimized Fl_Group::clear() and Fl_Scroll::clear() as discussed in
fltk.development in "Fl_Group::clear SLOW!" on Feb. 06/07, 2010 (no STR) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7038 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Scroll.cxx')
-rw-r--r--src/Fl_Scroll.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx
index 085d47bf0..333c4892d 100644
--- a/src/Fl_Scroll.cxx
+++ b/src/Fl_Scroll.cxx
@@ -32,13 +32,16 @@
/** Clear all but the scrollbars... */
void Fl_Scroll::clear() {
- for (int i=children() - 1; i >= 0; i --) {
- Fl_Widget* o = child(i);
- if (o != &hscrollbar && o != &scrollbar) {
- remove(o);
- delete o;
- }
- }
+ // Note: the scrollbars are removed from the group before
+ // calling Fl_Group::clear() to take advantage of the
+ // optimized widget removal. Finally they are added
+ // to the Fl_Scroll's group again.
+ // This is MUCH faster than removing each widget.
+ remove(scrollbar);
+ remove(hscrollbar);
+ Fl_Group::clear();
+ add(hscrollbar);
+ add(scrollbar);
}
/** Insure the scrollbars are the last children */