Eric, the FLTK version (1.3.4) you are using is more than 7 years
old which means that the issue you are reporting would very likely
have been fixed long ago. It's very surprising that the buffer
assignment alone would cause a delay of almost 7 seconds.
I would have suggested you to create a small, complete (i.e.
compileable) example program that shows the issue, and that you test
this program with a newer FLTK version, either 1.3.9 or 1.4.0 (git).
But then I decided to copy and modify your code snippet and to try
it myself. I removed only one statement and all the timer lines.
Result: I can't confirm the issue, neither with 1.3.4, 1.3.9 nor
1.4.0.
Here's my demo program with test results using 1.3.4 (built for this
test!) and 1.4.0:
```
$ cat test/hello.cxx
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Text_Editor.H>
#include <stdio.h>
int w = 800;
Fl_Double_Window *window = nullptr;
void close_cb(void *p) {
window->hide();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(w, 615, "TEST");
Fl_Text_Editor *caption_text = new Fl_Text_Editor(10, 10, w - 20, 125, "Caption Text: ");
caption_text->align(FL_ALIGN_LEFT);
caption_text->when(FL_WHEN_CHANGED);
Fl_Text_Buffer *caption_buf = new Fl_Text_Buffer();
caption_text->buffer(caption_buf);
caption_text->wrap_mode(Fl_Text_Editor::WRAP_AT_BOUNDS, 5);
window->end();
window->show(argc, argv);
printf("\nFL_API_VERSION = %d\n", FL_API_VERSION);
Fl::add_timeout(0.001, close_cb, nullptr);
return Fl::run();
}
$ fltk-config --compile test/hello.cxx && time ./hello
/usr/bin/c++ -I/usr/local/fltk/1.4-debug/include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -o hello test/hello.cxx /usr/local/fltk/1.4-debug/lib/libfltk.a -lm -lpthread -lXinerama -lXfixes -lXcursor -L/usr/lib/x86_64-linux-gnu -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lcairo -L/usr/lib/x86_64-linux-gnu -lcairo -lgtk-3 -lgdk-3 -lgio-2.0 -lX11 -lXft -lXrender -lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1 -lfontconfig -ldl
FL_API_VERSION = 10400
real 0m0.190s
user 0m0.153s
sys 0m0.032s
$ /git/fltk/branch-1.3/fltk-config --compile test/hello.cxx && time ./hello
g++ -I/git/fltk/branch-1.3 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -o 'hello' 'test/hello.cxx' /git/fltk/branch-1.3/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXinerama -lpthread -lm -lX11
FL_API_VERSION = 10304
real 0m0.075s
user 0m0.030s
sys 0m0.005s
```
I noticed that 1.4.0 was "significantly slower" (by about 0.12 sec,
which is not much), but 1.3.4 was really fast in all my tests. Note
that I ran all this on my Debian 10 (Bookworm) Linux system with a
recent CPU.
There must be something weird with your system. Please run my test
program and report your results. If you still see slow behavior with
this test program, please give us more information about your
system.