From 38fcf6d15cdf09591e7d7a142ad724164875e433 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 16 Nov 2014 19:31:29 +0100 Subject: rewritten View and Interface base classes using the Curiously Recurring Template Pattern. * without the one-view-per-buffer designs, many Scintilla send message (SSM) calls could be inlined * with the new design, this was no longer possible using the abstract base classes. the CRT pattern allows inlining again but introduces a strange level of code obscurity. * tests suggest that at high optimization levels, the one-view-per-buffer design and the CRT pattern reduces typical macro runtimes by 30% (e.g. for symbols-extract.tes). * only updated the NCurses UI for the time being --- src/interface.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/interface.cpp') diff --git a/src/interface.cpp b/src/interface.cpp index aecba4e..fcb1738 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -34,8 +34,9 @@ namespace SciTECO { +template void -View::set_representations(void) +View::set_representations(void) { static const char *reps[] = { "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", @@ -50,8 +51,9 @@ View::set_representations(void) } } +template void -View::initialize(void) +View::initialize(void) { ssm(SCI_SETFOCUS, TRUE); @@ -70,8 +72,11 @@ View::initialize(void) ssm(SCI_STYLESETBACK, STYLE_LINENUMBER, 0x000000); } +template class View; + +template void -Interface::UndoTokenShowView::run(void) +Interface::UndoTokenShowView::run(void) { /* * Implementing this here allows us to reference @@ -80,8 +85,17 @@ Interface::UndoTokenShowView::run(void) interface.show_view(view); } +template +template +void +Interface::UndoTokenInfoUpdate::run(void) +{ + interface.info_update(obj); +} + +template void -Interface::stdio_vmsg(MessageType type, const gchar *fmt, va_list ap) +Interface::stdio_vmsg(MessageType type, const gchar *fmt, va_list ap) { gchar buf[255]; @@ -103,12 +117,15 @@ Interface::stdio_vmsg(MessageType type, const gchar *fmt, va_list ap) } } +template void -Interface::process_notify(SCNotification *notify) +Interface::process_notify(SCNotification *notify) { #ifdef DEBUG g_printf("SCINTILLA NOTIFY: code=%d\n", notify->nmhdr.code); #endif } +template class Interface; + } /* namespace SciTECO */ -- cgit v1.2.3