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

Side by Side Diff: ui/gfx/vector_icons/vector_icons.cc.template

Issue 2620653004: Optimize GetPathForVectorIcon*, save ~290 KB on disk (Closed)
Patch Set: Add constexpr to another PathElement array definition Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // vector_icons.cc.template is used to generate vector_icons.cc. Edit the former 5 // vector_icons.cc.template is used to generate vector_icons.cc. Edit the former
6 // rather than the latter. 6 // rather than the latter.
7 7
8 #include "ui/gfx/vector_icons/vector_icons.h" 8 #include "ui/gfx/vector_icons/vector_icons.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "ui/gfx/vector_icon_types.h" 11 #include "ui/gfx/vector_icon_types.h"
12 12
13 #define ICON_TEMPLATE(icon_name, ...) \ 13 #define ICON_TEMPLATE(icon_name, ...) \
14 case VectorIconId::icon_name: {\ 14 case VectorIconId::icon_name: {\
15 static PathElement path[] = {__VA_ARGS__};\ 15 static constexpr PathElement path[] = {__VA_ARGS__};\
16 return path;\ 16 return path;\
17 } 17 }
18 18
19 namespace gfx { 19 namespace gfx {
20 20
21 #if defined(OS_WIN)
22 #pragma warning(push)
23
24 // Disable "function size suppresses optimizations" warning.
25 #pragma warning(disable: 4883)
26 #endif // defined(OS_WIN)
27
28 const PathElement* GetPathForVectorIcon(VectorIconId id) { 21 const PathElement* GetPathForVectorIcon(VectorIconId id) {
29 switch (id) { 22 switch (id) {
30 TEMPLATE_PLACEHOLDER 23 TEMPLATE_PLACEHOLDER
31 24
32 case VectorIconId::VECTOR_ICON_NONE: 25 case VectorIconId::VECTOR_ICON_NONE:
33 NOTREACHED(); 26 NOTREACHED();
34 return nullptr; 27 return nullptr;
35 } 28 }
36 29
37 NOTREACHED(); 30 NOTREACHED();
38 return nullptr; 31 return nullptr;
39 } 32 }
40 33
41 const PathElement* GetPathForVectorIconAt1xScale(VectorIconId id) { 34 const PathElement* GetPathForVectorIconAt1xScale(VectorIconId id) {
42 switch (id) { 35 switch (id) {
43 TEMPLATE_PLACEHOLDER_1X 36 TEMPLATE_PLACEHOLDER_1X
44 37
45 default: 38 default:
46 return GetPathForVectorIcon(id); 39 return GetPathForVectorIcon(id);
47 } 40 }
48 } 41 }
49 42
50 #if defined(OS_WIN)
51 #pragma warning(pop)
52 #endif // defined(OS_WIN)
53
54 } // namespace gfx 43 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698