Does setting the same "primitive" field repeatedly cause size to grow?

26 views
Skip to first unread message

vlo...@gmail.com

unread,
Apr 16, 2020, 4:53:48 PM4/16/20
to Cap'n Proto
I don't see this explicitly called out in https://capnproto.org/cxx.html but I just wanted to double-check that something like this:


capnp::MallocMessageBuilder builder;
auto msg = builder.initRoot<MyMessage>();
auto nested = msg.initSomeStruct();

for (int i = 0; i < 100000; i++) {
    nested.setField(i);
    write over the wire(nested);
}

Doesn't cause arena allocation & the serialized wire size is going to be constant for all messages (i.e. it's going to continue clobbering the existing space for that field). It sounded like the only situation
was around re-initializing an existing struct or copying messages in. Just wanted to make sure that my understanding is correct & setting non-pointer fields is fine. I imagine that probably lists of
primitives are immune to this.

Thanks,
Vitali

Ian Denhardt

unread,
Apr 16, 2020, 5:32:09 PM4/16/20
to Cap'n Proto, vlo...@gmail.com
Correct, setting a field with a primitive type will not allocate
additional space.

-Ian

Quoting vlo...@gmail.com (2020-04-16 16:53:46)
> I don't see this explicitly called out
> in� [1]https://capnproto.org/cxx.html� but I just wanted to
> --
> You received this message because you are subscribed to the Google
> Groups "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [2]capnproto+...@googlegroups.com.
> To view this discussion on the web visit
> [3]https://groups.google.com/d/msgid/capnproto/7b2db4bb-f017-43ec-933f-
> 939f11246e2d%40googlegroups.com.
>
> Verweise
>
> 1. https://capnproto.org/cxx.html
> 2. mailto:capnproto+...@googlegroups.com
> 3. https://groups.google.com/d/msgid/capnproto/7b2db4bb-f017-43ec-933f-939f11246e2d%40googlegroups.com?utm_medium=email&utm_source=footer
Reply all
Reply to author
Forward
0 new messages