Merge lp:~vanvugt/compiz/fix-1005569.1 into lp:compiz/0.9.8

Proposed by Daniel van Vugt
Status: Merged
Merged at revision: 3236
Proposed branch: lp:~vanvugt/compiz/fix-1005569.1
Merge into: lp:compiz/0.9.8
Diff against target: 74 lines (+20/-15)
1 file modified
src/event.cpp (+20/-15)
To merge this branch: bzr merge lp:~vanvugt/compiz/fix-1005569.1
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
Review via email: mp+107942@code.launchpad.net

Description of the change

Avoid constructing and destructing lots of strings on every single event,
which was wasting lots of CPU (LP: #1005569)

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

I'm fine with this going in as is, but the code needs to be redesigned tbh, the abstraction is terrible.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/event.cpp'
2--- src/event.cpp 2012-05-27 04:32:55 +0000
3+++ src/event.cpp 2012-05-30 09:31:21 +0000
4@@ -649,15 +649,19 @@
5 bool
6 PrivateScreen::handleActionEvent (XEvent *event)
7 {
8- static CompOption::Vector o (8);
9+ static CompOption::Vector o;
10 Window xid;
11
12- o[0].setName ("event_window", CompOption::TypeInt);
13- o[1].setName ("window", CompOption::TypeInt);
14- o[2].setName ("modifiers", CompOption::TypeInt);
15- o[3].setName ("x", CompOption::TypeInt);
16- o[4].setName ("y", CompOption::TypeInt);
17- o[5].setName ("root", CompOption::TypeInt);
18+ if (o.empty ())
19+ {
20+ o.resize (8);
21+ o[0].setName ("event_window", CompOption::TypeInt);
22+ o[1].setName ("window", CompOption::TypeInt);
23+ o[2].setName ("modifiers", CompOption::TypeInt);
24+ o[3].setName ("x", CompOption::TypeInt);
25+ o[4].setName ("y", CompOption::TypeInt);
26+ o[5].setName ("root", CompOption::TypeInt);
27+ }
28 o[6].reset ();
29 o[7].reset ();
30
31@@ -937,6 +941,14 @@
32 if (event->type == xkbEvent.get())
33 {
34 XkbAnyEvent *xkbEvent = (XkbAnyEvent *) event;
35+ static CompOption::Vector o;
36+
37+ if (o.empty ())
38+ {
39+ o.resize (8);
40+ o[0].setName ("event_window", CompOption::TypeInt);
41+ o[1].setName ("window", CompOption::TypeInt);
42+ }
43
44 if (xkbEvent->xkb_type == XkbStateNotify)
45 {
46@@ -944,13 +956,10 @@
47
48 o[0].value ().set ((int) orphanData.activeWindow);
49 o[1].value ().set ((int) orphanData.activeWindow);
50+ o[2].setName ("modifiers", CompOption::TypeInt);
51 o[2].value ().set ((int) stateEvent->mods);
52-
53 o[3].setName ("time", CompOption::TypeInt);
54 o[3].value ().set ((int) xkbEvent->time);
55- o[4].reset ();
56- o[5].reset ();
57- o[6].reset ();
58 o[7].value ().set ((int) xkbEvent->time);
59
60 if (stateEvent->event_type == KeyPress)
61@@ -967,13 +976,9 @@
62 {
63 o[0].value ().set ((int) orphanData.activeWindow);
64 o[1].value ().set ((int) orphanData.activeWindow);
65-
66 o[2].setName ("time", CompOption::TypeInt);
67 o[2].value ().set ((int) xkbEvent->time);
68 o[3].reset ();
69- o[4].reset ();
70- o[5].reset ();
71-
72
73 foreach (CompPlugin *p, CompPlugin::getPlugins ())
74 {

Subscribers

People subscribed via source and target branches