mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 04:52:59 +01:00
Refactor define::msgpack_unpack() to use 'switch' instead of several if's.
convert.benchmark test show some improvement.
This commit is contained in:
parent
98c5767372
commit
d47f72be0c
@ -107,8 +107,15 @@ struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
|||||||
{
|
{
|
||||||
if(o.type != type::ARRAY) { throw type_error(); }
|
if(o.type != type::ARRAY) { throw type_error(); }
|
||||||
const size_t size = o.via.array.size;
|
const size_t size = o.via.array.size;
|
||||||
<%0.upto(i) {|j|%>
|
if(size > 0) {
|
||||||
if(size <= <%=j%>) { return; } o.via.array.ptr[<%=j%>].convert(&a<%=j%>);<%}%>
|
msgpack::object *ptr = o.via.array.ptr;
|
||||||
|
switch(size) {
|
||||||
|
default:
|
||||||
|
<%(i).downto(0) {|j|%>
|
||||||
|
case <%=j+1%>: ptr[<%=j%>].convert(&a<%=j%>);<%}%>
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void msgpack_object(msgpack::object* o, msgpack::zone* z) const
|
void msgpack_object(msgpack::object* o, msgpack::zone* z) const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user