dc_array: introduce MsgIds variant

This avoids allocation of u32 vector.
This commit is contained in:
Alexander Krotov
2020-06-24 20:50:51 +03:00
committed by link2xt
parent 2c11df46a7
commit 09833eb74d
2 changed files with 16 additions and 12 deletions

View File

@@ -830,14 +830,11 @@ pub unsafe extern "C" fn dc_get_chat_msgs(
};
block_on(async move {
let arr = dc_array_t::from(
Box::into_raw(Box::new(
chat::get_chat_msgs(&ctx, ChatId::new(chat_id), flags, marker_flag)
.await
.iter()
.map(|msg_id| msg_id.to_u32())
.collect::<Vec<u32>>(),
);
Box::into_raw(Box::new(arr))
.into(),
))
})
}
@@ -966,7 +963,7 @@ pub unsafe extern "C" fn dc_get_chat_media(
from_prim(or_msg_type3).expect(&format!("incorrect or_msg_type3 = {}", or_msg_type3));
block_on(async move {
let arr = dc_array_t::from(
Box::into_raw(Box::new(
chat::get_chat_media(
&ctx,
ChatId::new(chat_id),
@@ -975,11 +972,8 @@ pub unsafe extern "C" fn dc_get_chat_media(
or_msg_type3,
)
.await
.iter()
.map(|msg_id| msg_id.to_u32())
.collect::<Vec<u32>>(),
);
Box::into_raw(Box::new(arr))
.into(),
))
})
}