From d452a0cdba9ebb5a2f674d62fcbaa1f318454e15 Mon Sep 17 00:00:00 2001 From: Michal Labedzki Date: Sun, 29 Jan 2017 19:03:51 +0100 Subject: Logcat-text: use GRegex optimizations "G_REGEX_OPTIMIZE - Optimize the regular expression. If the pattern will be used many times, then it may be worth the effort to optimize it to improve the speed of matches." - Glib documentation. It is possible to capture a lot of Logcat logs or these log may flooding us. Optimizations are welcome. Change-Id: If753e795efe30b014a5fad11c8ebbcd4da3824a6 Reviewed-on: https://code.wireshark.org/review/20357 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/dissectors/packet-logcat-text.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'epan/dissectors/packet-logcat-text.c') diff --git a/epan/dissectors/packet-logcat-text.c b/epan/dissectors/packet-logcat-text.c index 970101da6e..e13614499a 100644 --- a/epan/dissectors/packet-logcat-text.c +++ b/epan/dissectors/packet-logcat-text.c @@ -304,14 +304,14 @@ static int dissect_logcat_text_long(tvbuff_t *tvb, packet_info *pinfo, proto_tre static void logcat_text_init(void) { - special_regex = g_regex_new(SPECIAL_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - brief_regex = g_regex_new(BRIEF_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - tag_regex = g_regex_new(TAG_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - time_regex = g_regex_new(TIME_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - thread_regex = g_regex_new(THREAD_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - threadtime_regex = g_regex_new(THREADTIME_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - process_regex = g_regex_new(PROCESS_STRING, G_REGEX_ANCHORED, G_REGEX_MATCH_NOTEMPTY, NULL); - long_regex = g_regex_new(LONG_STRING, G_REGEX_MULTILINE, G_REGEX_MATCH_NOTEMPTY, NULL); + special_regex = g_regex_new(SPECIAL_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + brief_regex = g_regex_new(BRIEF_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + tag_regex = g_regex_new(TAG_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + time_regex = g_regex_new(TIME_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + thread_regex = g_regex_new(THREAD_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + threadtime_regex = g_regex_new(THREADTIME_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + process_regex = g_regex_new(PROCESS_STRING, (GRegexCompileFlags)(G_REGEX_ANCHORED | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); + long_regex = g_regex_new(LONG_STRING, (GRegexCompileFlags)(G_REGEX_MULTILINE | G_REGEX_OPTIMIZE), G_REGEX_MATCH_NOTEMPTY, NULL); } static void logcat_text_cleanup(void) -- cgit v1.2.3