@@ -90,11 +90,9 @@ class PgConfCompletionProvider implements vscode.CompletionItemProvider {
9090 * XXX: When implementing we should keep in mind, that
9191 * TS/JS is slow and likes to allocate huge memory, so
9292 * prefer simple, but faster algorithms.
93- *
94- * TODO: for fast prefix filter use binary search, not full scan
9593 */
9694 const param = document . getText ( range ) ;
97- const parameters = constants . getWellKnownConfigurationParameters ( ) ;
95+ const parameters = this . getGUCs ( ) ;
9896 const prefixRange = getParamsByPrefix ( parameters , param ) ;
9997 if ( prefixRange === undefined ) {
10098 return ;
@@ -108,6 +106,26 @@ class PgConfCompletionProvider implements vscode.CompletionItemProvider {
108106 return parameters . slice ( ...prefixRange ) . map ( p => new vscode . CompletionItem ( p ) ) ;
109107 }
110108 }
109+
110+ private getGUCs ( ) {
111+ /*
112+ * Use only builtin GUCs, because tracking contribs is hard task.
113+ * We of course can traverse 'contrib/' directory and find all *.c
114+ * files - that what I did just now.
115+ *
116+ * But this approach gives another pain - resources consumption, IO,
117+ * CPU and memory. When I tested such logic on medium sized contrib dir
118+ * I faced high CPU consumption (even fans started making noise) and
119+ * memory (extension profiler showed up to 1GB heap size with sawtooth
120+ * shaped graph).
121+ *
122+ * Another approach is to keep track of all contribs in code, i.e. have
123+ * another 'contribGucs' in 'constants.ts' with Map contrib -> it's GUCs,
124+ * but it will require to constant monitoring for changes, which is now
125+ * doesn't sound appealing yet.
126+ */
127+ return constants . getWellKnownConfigurationParameters ( ) ;
128+ }
111129}
112130
113131export function setupPgConfSupport ( context : vscode . ExtensionContext ) {
0 commit comments