未验证 提交 f3ec23ac 编写于 作者: W wanderingbort 提交者: GitHub

Merge pull request #6501 from EOSIO/feature/port-assign-change

optimization when writing shared_blob data
......@@ -521,9 +521,8 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table,
const auto& obj = db.create<key_value_object>( [&]( auto& o ) {
o.t_id = tableid;
o.primary_key = id;
o.value.resize( buffer_size );
o.value.assign( buffer, buffer_size );
o.payer = payer;
memcpy( o.value.data(), buffer, buffer_size );
});
db.modify( tab, [&]( auto& t ) {
......@@ -562,8 +561,7 @@ void apply_context::db_update_i64( int iterator, account_name payer, const char*
}
db.modify( obj, [&]( auto& o ) {
o.value.resize( buffer_size );
memcpy( o.value.data(), buffer, buffer_size );
o.value.assign( buffer, buffer_size );
o.payer = payer;
});
}
......
......@@ -155,10 +155,11 @@ void apply_eosio_setcode(apply_context& context) {
// TODO: update setcode message to include the hash, then validate it in validate
a.last_code_update = context.control.pending_block_time();
a.code_version = code_id;
a.code.resize( code_size );
if( code_size > 0 )
memcpy( a.code.data(), act.code.data(), code_size );
if ( code_size > 0 ) {
a.code.assign(act.code.data(), code_size);
} else {
a.code.resize(0);
}
});
const auto& account_sequence = db.get<account_sequence_object, by_name>(act.account);
......@@ -185,9 +186,11 @@ void apply_eosio_setabi(apply_context& context) {
int64_t new_size = abi_size;
db.modify( account, [&]( auto& a ) {
a.abi.resize( abi_size );
if( abi_size > 0 )
memcpy( a.abi.data(), act.abi.data(), abi_size );
if (abi_size > 0) {
a.abi.assign(act.abi.data(), abi_size);
} else {
a.abi.resize(0);
}
});
const auto& account_sequence = db.get<account_sequence_object, by_name>(act.account);
......
......@@ -103,7 +103,22 @@ namespace eosio { namespace chain {
*/
class shared_blob : public shared_string {
public:
shared_blob() = default;
shared_blob() = delete;
shared_blob(shared_blob&&) = default;
shared_blob(const shared_blob& s)
:shared_string(s.get_allocator())
{
assign(s.c_str(), s.size());
}
shared_blob& operator=(const shared_blob& s) {
assign(s.c_str(), s.size());
return *this;
}
shared_blob& operator=(shared_blob&& ) = default;
template <typename InputIterator>
shared_blob(InputIterator f, InputIterator l, const allocator_type& a)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册