diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2010-10-12 08:12:44 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2010-10-12 08:12:44 +0000 |
| commit | aea80474f83432b6a858358c45d9117a598f2aaf (patch) | |
| tree | 0993a81356f8fa110f562e16e3befa3ea24581e9 /src/Fl_Scroll.cxx | |
| parent | e1e119e1df89fee4d0111504fb3ce57a2c65bed0 (diff) | |
Optimized Fl_Group::clear() and Fl_Scroll::clear(). This speeds
up mass deletes (lots of children in a group) significantly.
See also STR #2409.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7718 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Scroll.cxx')
| -rw-r--r-- | src/Fl_Scroll.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx index 085d47bf0..0089524dd 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 + // and deletion. Finally they are added to Fl_Scroll's group again. This + // is MUCH faster than removing the widgets one by one (STR #2409). + + remove(scrollbar); + remove(hscrollbar); + Fl_Group::clear(); + add(hscrollbar); + add(scrollbar); } /** Insure the scrollbars are the last children */ |
