aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-03-25 19:55:43 +0100
committerSverker Eriksson <[email protected]>2015-03-25 19:55:43 +0100
commit5d5543fb1e1a30e4572e90bac2ec194a61ca4e30 (patch)
tree7108a5f258f0a17abc39347ff8dd98f5b462c65a
parent1f3869b308af19fb9cf471a12b8a1fdeab9da290 (diff)
downloadotp-5d5543fb1e1a30e4572e90bac2ec194a61ca4e30.tar.gz
otp-5d5543fb1e1a30e4572e90bac2ec194a61ca4e30.tar.bz2
otp-5d5543fb1e1a30e4572e90bac2ec194a61ca4e30.zip
erts: Optimize term_to_binary size estimation
for tuples and maps containing ascii strings (lists).
-rw-r--r--erts/emulator/beam/external.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
index b0b232f185..4cd57d8aeb 100644
--- a/erts/emulator/beam/external.c
+++ b/erts/emulator/beam/external.c
@@ -4109,8 +4109,9 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj,
}
for (i = 1; i <= arity; ++i) {
if (is_list(ptr[i])) {
- if ((m = is_string(obj)) && (m < MAX_STRING_LEN)) {
+ if ((m = is_string(ptr[i])) && (m < MAX_STRING_LEN)) {
result += m + 2 + 1;
+ continue;
} else {
result += 5;
}
@@ -4131,31 +4132,29 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj,
/* push values first */
ptr = flatmap_get_values(mp);
- i = size;
- while(i--) {
+ for (i = size; i; i--, ptr++) {
if (is_list(*ptr)) {
if ((m = is_string(*ptr)) && (m < MAX_STRING_LEN)) {
result += m + 2 + 1;
+ continue;
} else {
result += 5;
}
}
ESTACK_PUSH(s,*ptr);
- ++ptr;
}
ptr = flatmap_get_keys(mp);
- i = size;
- while(i--) {
+ for (i = size; i; i--, ptr++) {
if (is_list(*ptr)) {
if ((m = is_string(*ptr)) && (m < MAX_STRING_LEN)) {
result += m + 2 + 1;
+ continue;
} else {
result += 5;
}
}
ESTACK_PUSH(s,*ptr);
- ++ptr;
}
goto outer_loop;
}