mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
evdev: Cache the regexp
Instead of recreating it for every new device, we can cache the GRegex and reuse it. https://bugzilla.gnome.org/show_bug.cgi?id=707901
This commit is contained in:
parent
a26690a73d
commit
9eb479aeef
@ -820,13 +820,15 @@ find_source_by_device (ClutterDeviceManagerEvdev *manager,
|
|||||||
static gboolean
|
static gboolean
|
||||||
is_evdev (const gchar *sysfs_path)
|
is_evdev (const gchar *sysfs_path)
|
||||||
{
|
{
|
||||||
GRegex *regex;
|
static GRegex *regex = NULL;
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
regex = g_regex_new ("/input[0-9]+/event[0-9]+$", 0, 0, NULL);
|
/* cache the regexp */
|
||||||
|
if (G_UNLIKELY (regex == NULL))
|
||||||
|
regex = g_regex_new ("/input[0-9]+/event[0-9]+$", 0, 0, NULL);
|
||||||
|
|
||||||
match = g_regex_match (regex, sysfs_path, 0, NULL);
|
match = g_regex_match (regex, sysfs_path, 0, NULL);
|
||||||
|
|
||||||
g_regex_unref (regex);
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user