Reduce compiled code size

If the number of arguments is less than MAX_PACKED_ARGS, pass
the arguments as a Value array rather than Arg array.
This commit is contained in:
vitaut
2015-04-20 10:02:41 -07:00
parent 62c483c940
commit 8d2559bd96
2 changed files with 83 additions and 32 deletions
+17 -6
View File
@@ -423,7 +423,7 @@ ARG_INFO(POINTER, const void *, pointer);
ARG_INFO(CUSTOM, Arg::CustomValue, custom);
#define CHECK_ARG_INFO(Type, field, value) { \
Arg arg = {}; \
Arg arg = Arg(); \
arg.field = value; \
EXPECT_EQ(value, ArgInfo<Arg::Type>::get(arg)); \
}
@@ -442,7 +442,7 @@ TEST(ArgTest, ArgInfo) {
CHECK_ARG_INFO(WSTRING, wstring.value, WSTR);
int p = 0;
CHECK_ARG_INFO(POINTER, pointer, &p);
Arg arg = {};
Arg arg = Arg();
arg.custom.value = &p;
EXPECT_EQ(&p, ArgInfo<Arg::CUSTOM>::get(arg).value);
}
@@ -844,17 +844,28 @@ TEST(UtilTest, IsEnumConvertibleToInt) {
template <typename T>
bool check_enable_if(
typename fmt::internal::EnableIf<sizeof(T) == sizeof(int), T>::type) {
typename fmt::internal::EnableIf<sizeof(T) == sizeof(int), T>::type *) {
return true;
}
template <typename T>
bool check_enable_if(
typename fmt::internal::EnableIf<sizeof(T) != sizeof(int), T>::type) {
typename fmt::internal::EnableIf<sizeof(T) != sizeof(int), T>::type *) {
return false;
}
TEST(UtilTest, EnableIf) {
EXPECT_TRUE(check_enable_if<int>(42));
EXPECT_FALSE(check_enable_if<char>('a'));
int i = 0;
EXPECT_TRUE(check_enable_if<int>(&i));
char c = 0;
EXPECT_FALSE(check_enable_if<char>(&c));
}
TEST(UtilTest, Conditional) {
int i = 0;
fmt::internal::Conditional<true, int, char>::type *pi = &i;
(void)pi;
char c = 0;
fmt::internal::Conditional<false, int, char>::type *pc = &c;
(void)pc;
}