summaryrefslogtreecommitdiffstats
path: root/services/inputflinger
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-12-24 10:37:38 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-12-24 10:37:38 +0000
commita3ef067c0080253fb9adc0867792c19e882f015a (patch)
treec70abac8f8dff98926f72a4ff35f92fdba77e665 /services/inputflinger
parent13b609aa4de83e30b64de51d2b1c8cab6a072316 (diff)
parent106547c1e33453b7e20b7b387087092d36aa6a72 (diff)
downloadframeworks_native-a3ef067c0080253fb9adc0867792c19e882f015a.zip
frameworks_native-a3ef067c0080253fb9adc0867792c19e882f015a.tar.gz
frameworks_native-a3ef067c0080253fb9adc0867792c19e882f015a.tar.bz2
am 106547c1: am 033f7e8e: Merge "InputDispatcher: Optimize count()"
* commit '106547c1e33453b7e20b7b387087092d36aa6a72': InputDispatcher: Optimize count()
Diffstat (limited to 'services/inputflinger')
-rw-r--r--services/inputflinger/InputDispatcher.cpp12
-rw-r--r--services/inputflinger/InputDispatcher.h11
2 files changed, 9 insertions, 14 deletions
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index 603836a..9157bc1 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -3789,18 +3789,6 @@ void InputDispatcher::monitor() {
}
-// --- InputDispatcher::Queue ---
-
-template <typename T>
-uint32_t InputDispatcher::Queue<T>::count() const {
- uint32_t result = 0;
- for (const T* entry = head; entry; entry = entry->next) {
- result += 1;
- }
- return result;
-}
-
-
// --- InputDispatcher::InjectionState ---
InputDispatcher::InjectionState::InjectionState(int32_t injectorPid, int32_t injectorUid) :
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
index 70b0a34..8c78a44 100644
--- a/services/inputflinger/InputDispatcher.h
+++ b/services/inputflinger/InputDispatcher.h
@@ -606,8 +606,9 @@ private:
struct Queue {
T* head;
T* tail;
+ uint32_t entryCount;
- inline Queue() : head(NULL), tail(NULL) {
+ inline Queue() : head(NULL), tail(NULL), entryCount(0) {
}
inline bool isEmpty() const {
@@ -615,6 +616,7 @@ private:
}
inline void enqueueAtTail(T* entry) {
+ entryCount++;
entry->prev = tail;
if (tail) {
tail->next = entry;
@@ -626,6 +628,7 @@ private:
}
inline void enqueueAtHead(T* entry) {
+ entryCount++;
entry->next = head;
if (head) {
head->prev = entry;
@@ -637,6 +640,7 @@ private:
}
inline void dequeue(T* entry) {
+ entryCount--;
if (entry->prev) {
entry->prev->next = entry->next;
} else {
@@ -650,6 +654,7 @@ private:
}
inline T* dequeueAtHead() {
+ entryCount--;
T* entry = head;
head = entry->next;
if (head) {
@@ -660,7 +665,9 @@ private:
return entry;
}
- uint32_t count() const;
+ uint32_t count() const {
+ return entryCount;
+ }
};
/* Specifies which events are to be canceled and why. */