Ignore:
Timestamp:
Apr 27, 2011, 5:52:28 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) more heap pruning: avoid an unnecessary evbuffer_new() + evbuffer_free() in tr_peerIoWriteBytes()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r12365 r12386  
    10601060tr_peerIoWriteBytes( tr_peerIo * io, const void * bytes, size_t byteCount, bool isPieceData )
    10611061{
    1062     struct evbuffer * buf = evbuffer_new( );
    1063     evbuffer_add( buf, bytes, byteCount );
    1064     tr_peerIoWriteBuf( io, buf, isPieceData );
    1065     evbuffer_free( buf );
     1062    struct evbuffer_iovec iovec;
     1063    evbuffer_reserve_space( io->outbuf, byteCount, &iovec, 1 );
     1064
     1065    iovec.iov_len = byteCount;
     1066    if( io->encryption_type == PEER_ENCRYPTION_RC4 )
     1067        tr_cryptoEncrypt( &io->crypto, iovec.iov_len, bytes, iovec.iov_base );
     1068    else
     1069        memcpy( iovec.iov_base, bytes, iovec.iov_len );
     1070    evbuffer_commit_space( io->outbuf, &iovec, 1 );
     1071
     1072    addDatatype( io, byteCount, isPieceData );
    10661073}
    10671074
Note: See TracChangeset for help on using the changeset viewer.