Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: ui/events/gesture_detection/gesture_event_data_packet.h

Issue 403173004: Avoid heap allocations with GestureEventDataPacket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win build Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/events.gyp ('k') | ui/events/gesture_detection/gesture_event_data_packet.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gesture_detection/gesture_event_data_packet.h
diff --git a/ui/events/gesture_detection/gesture_event_data_packet.h b/ui/events/gesture_detection/gesture_event_data_packet.h
index 0c40f5767849c1bbea4a69c05df9286f1998c106..9b115de9ca77b29c2210b4933cd9a78acbb69198 100644
--- a/ui/events/gesture_detection/gesture_event_data_packet.h
+++ b/ui/events/gesture_detection/gesture_event_data_packet.h
@@ -5,8 +5,7 @@
#ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
#define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
-#include <vector>
-
+#include "base/containers/stack_container.h"
#include "ui/events/gesture_detection/gesture_detection_export.h"
#include "ui/events/gesture_detection/gesture_event_data.h"
@@ -44,7 +43,7 @@ class GESTURE_DETECTION_EXPORT GestureEventDataPacket {
const base::TimeTicks& timestamp() const { return timestamp_; }
const GestureEventData& gesture(size_t i) const { return gestures_[i]; }
- size_t gesture_count() const { return gestures_.size(); }
+ size_t gesture_count() const { return gestures_->size(); }
GestureSource gesture_source() const { return gesture_source_; }
const gfx::PointF& touch_location() const { return touch_location_; }
const gfx::PointF& raw_touch_location() const { return raw_touch_location_; }
@@ -55,9 +54,9 @@ class GESTURE_DETECTION_EXPORT GestureEventDataPacket {
const gfx::PointF& touch_location,
const gfx::PointF& raw_touch_location);
+ enum { kTypicalMaxGesturesPerTouch = 5 };
base::TimeTicks timestamp_;
- // TODO(jdduke): This vector is in general very short. Optimize?
- std::vector<GestureEventData> gestures_;
+ base::StackVector<GestureEventData, kTypicalMaxGesturesPerTouch> gestures_;
gfx::PointF touch_location_;
gfx::PointF raw_touch_location_;
GestureSource gesture_source_;
« no previous file with comments | « ui/events/events.gyp ('k') | ui/events/gesture_detection/gesture_event_data_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698