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
|
||||
is_evdev (const gchar *sysfs_path)
|
||||
{
|
||||
GRegex *regex;
|
||||
static GRegex *regex = NULL;
|
||||
gboolean match;
|
||||
|
||||
/* 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);
|
||||
|
||||
g_regex_unref (regex);
|
||||
return match;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user