28
28
#include "mainloop.h"
29
29
#include "stats/stats-registry.h"
30
30
#include "stats/stats-cluster-single.h"
31
+ #include "perf/perf.h"
32
+
33
+ static inline gboolean
34
+ _extract_source_text (void )
35
+ {
36
+ return debug_flag || perf_is_enabled ();
37
+ }
31
38
32
39
void
33
40
filterx_expr_set_location_with_text (FilterXExpr * self , CFG_LTYPE * lloc , const gchar * text )
@@ -36,7 +43,7 @@ filterx_expr_set_location_with_text(FilterXExpr *self, CFG_LTYPE *lloc, const gc
36
43
self -> lloc = g_new0 (CFG_LTYPE , 1 );
37
44
* self -> lloc = * lloc ;
38
45
39
- if (debug_flag && text && text != self -> expr_text )
46
+ if (_extract_source_text () && text && text != self -> expr_text )
40
47
{
41
48
g_free (self -> expr_text );
42
49
self -> expr_text = g_strdup (text );
@@ -49,7 +56,7 @@ filterx_expr_set_location(FilterXExpr *self, CfgLexer *lexer, CFG_LTYPE *lloc)
49
56
if (!self -> lloc )
50
57
self -> lloc = g_new0 (CFG_LTYPE , 1 );
51
58
* self -> lloc = * lloc ;
52
- if (debug_flag )
59
+ if (_extract_source_text () )
53
60
{
54
61
g_free (self -> expr_text );
55
62
GString * res = g_string_sized_new (0 );
@@ -106,6 +113,17 @@ filterx_expr_optimize(FilterXExpr *self)
106
113
gboolean
107
114
filterx_expr_init_method (FilterXExpr * self , GlobalConfig * cfg )
108
115
{
116
+ if (perf_is_enabled ())
117
+ {
118
+ gchar buf [256 ];
119
+
120
+ if (self -> expr_text )
121
+ g_snprintf (buf , sizeof (buf ), "filterx::%s" , self -> expr_text );
122
+ else
123
+ g_snprintf (buf , sizeof (buf ), "filterx::@%s" , self -> type );
124
+ self -> eval = perf_generate_trampoline (self -> eval , buf );
125
+ }
126
+
109
127
return TRUE;
110
128
}
111
129
0 commit comments