Ignore:
Timestamp:
Apr 4, 2011, 4:45:41 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) when reading piece data in from a socket, avoid two unnecessary calls to memcpy()

File:
1 edited

Legend:

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

    r12282 r12303  
    10621062
    10631063void
     1064tr_peerIoReadBytesToBuf( tr_peerIo * io, struct evbuffer * inbuf, struct evbuffer * outbuf, size_t byteCount )
     1065{
     1066    const size_t old_length = evbuffer_get_length( outbuf );
     1067
     1068    assert( tr_isPeerIo( io ) );
     1069    assert( evbuffer_get_length( inbuf )  >= byteCount );
     1070
     1071    /* append it to outbuf */
     1072    evbuffer_remove_buffer( inbuf, outbuf, byteCount );
     1073
     1074    /* decrypt if needed */
     1075    if( io->encryption_type == PEER_ENCRYPTION_RC4 ) {
     1076        struct evbuffer_ptr pos;
     1077        struct evbuffer_iovec iovec;
     1078        evbuffer_ptr_set( outbuf, &pos, old_length, EVBUFFER_PTR_SET );
     1079        do {
     1080           evbuffer_peek( outbuf, byteCount, &pos, &iovec, 1 );
     1081            tr_cryptoDecrypt( io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base );
     1082        } while( !evbuffer_ptr_set( outbuf, &pos, iovec.iov_len, EVBUFFER_PTR_ADD ) );
     1083    }
     1084}
     1085
     1086void
    10641087tr_peerIoReadBytes( tr_peerIo * io, struct evbuffer * inbuf, void * bytes, size_t byteCount )
    10651088{
     
    11071130                size_t            byteCount )
    11081131{
    1109     void * buf = tr_sessionGetBuffer( io->session );
    1110     const size_t buflen = SESSION_BUFFER_SIZE;
     1132    char buf[4096];
     1133    const size_t buflen = sizeof( buf );
    11111134
    11121135    while( byteCount > 0 )
     
    11161139        byteCount -= thisPass;
    11171140    }
    1118 
    1119     tr_sessionReleaseBuffer( io->session );
    11201141}
    11211142
Note: See TracChangeset for help on using the changeset viewer.