Greatly improve performance for TcpSocketBuf.read
Greatly improve performance for TcpSocketBuf.read

For every call to the read() function the internal buffer was copied
into a new buffer (minus the bytes copied into the result buffer). When
the internal buffer is large enough, this severely affects performance,
especially when read_line() is used which calls read_byte() (which calls
read()) for each read byte.

For line oriented I/O this wasn't all that bad, because the internal
buffers usually never were very big. The effect is much more visible
once the buffer grows larger.

Now we always first look into the internal buffer and copy as many bytes
as possible (and desired) into the result buffer. If we need more, we
call the socket read function and use the result as the new internal
buffer, then continue to copy from the (new) internal buffer, and so on.

aneeshusa/rust,Ryman/rust,pelmers/rust,0x73/rust,XMPPwocky/rust,ebfull/rust,aepsil0n/rust,AerialX/rust,AerialX/rust,andars/rust,erickt/rust,avdi/rust,quornian/rust,quornian/rust,vhbit/rust,ktossell/rust,j16r/rust,kmcallister/rust,servo/rust,robertg/rust,SiegeLord/rust,nham/rust,michaelballantyne/rust-gpu,victorvde/rust,zubron/rust,cllns/rust,dwillmer/rust,aepsil0n/rust,SiegeLord/rust,ktossell/rust,victorvde/rust,quornian/rust,hauleth/rust,LeoTestard/rust,richo/rust,zachwick/rust,reem/rust,miniupnp/rust,sae-bom/rust,aturon/rust,stepancheg/rust-ide-rust,ejjeong/rust,philyoon/rust,bombless/rust,shepmaster/rand,j16r/rust,barosl/rust,andars/rust,AerialX/rust-rt-minimal,erickt/rust,michaelballantyne/rust-gpu,dwillmer/rust,zaeleus/rust,TheNeikos/rust,nham/rust,zubron/rust,l0kod/rust,robertg/rust,l0kod/rust,dinfuehr/rust,l0kod/rust,KokaKiwi/rust,miniupnp/rust,ejjeong/rust,barosl/rust,l0kod/rust,zubron/rust,sarojaba/rust-doc-korean,hauleth/rust,hauleth/rust,0x73/rust,mitsuhiko/rust,stepancheg/rust-ide-rust,ebfull/rust,kmcallister/rust,quornian/rust,P1start/rust,mahkoh/rust,j16r/rust,P1start/rust,AerialX/rust,stepancheg/rust-ide-rust,vhbit/rust,ktossell/rust,vhbit/rust,zaeleus/rust,seanrivera/rust,LeoTestard/rust,omasanori/rust,ebfull/rust,mitsuhiko/rust,rohitjoshi/rust,XMPPwocky/rust,aidancully/rust,rprichard/rust,GBGamer/rust,zachwick/rust,defuz/rust,barosl/rust,krzysz00/rust,richo/rust,rprichard/rust,waynenilsen/rand,rohitjoshi/rust,mihneadb/rust,barosl/rust,jroesch/rust,aturon/rust,dwillmer/rust,gifnksm/rust,achanda/rand,dinfuehr/rust,jroesch/rust,andars/rust,AerialX/rust-rt-minimal,sae-bom/rust,jroesch/rust,Ryman/rust,pythonesque/rust,defuz/rust,mihneadb/rust,mahkoh/rust,P1start/rust,bluss/rand,omasanori/rust,bombless/rust,hauleth/rust,ejjeong/rust,carols10cents/rust,robertg/rust,nham/rust,aneeshusa/rust,dwillmer/rust,robertg/rust,kmcallister/rust,jbclements/rust,dwillmer/rust,emk/rust,emk/rust,untitaker/rust,seanrivera/rust,XMPPwocky/rust,mihneadb/rust,nham/rust,LeoTestard/rust,aturon/rust,nwin/rust,victorvde/rust,jbclements/rust,nham/rust,pshc/rust,defuz/rust,victorvde/rust,kimroen/rust,ruud-v-a/rust,kwantam/rust,ejjeong/rust,erickt/rust,rohitjoshi/rust,LeoTestard/rust,jroesch/rust,cllns/rust,AerialX/rust-rt-minimal,rohitjoshi/rust,cllns/rust,sarojaba/rust-doc-korean,aneeshusa/rust,robertg/rust,fabricedesre/rust,untitaker/rust,kwantam/rust,cllns/rust,Ryman/rust,miniupnp/rust,pythonesque/rust,l0kod/rust,AerialX/rust-rt-minimal,reem/rust,rohitjoshi/rust,ruud-v-a/rust,barosl/rust,dinfuehr/rust,mdinger/rust,mitsuhiko/rust,aneeshusa/rust,aidancully/rust,TheNeikos/rust,ktossell/rust,servo/rust,AerialX/rust,emk/rust,mitsuhiko/rust,pczarn/rust,erickt/rust,pshc/rust,untitaker/rust,jbclements/rust,miniupnp/rust,0x73/rust,servo/rust,ebfull/rust,fabricedesre/rust,zubron/rust,erickt/rust,Ryman/rust,0x73/rust,mdinger/rust,ebfull/rust,j16r/rust,bhickey/rand,krzysz00/rust,0x73/rust,rprichard/rust,kimroen/rust,bombless/rust-docs-chinese,mahkoh/rust,SiegeLord/rust,rprichard/rust,philyoon/rust,zubron/rust,carols10cents/rust,vhbit/rust,kmcallister/rust,P1start/rust,P1start/rust,erickt/rust,retep998/rand,GBGamer/rust,pythonesque/rust,aidancully/rust,sarojaba/rust-doc-korean,zachwick/rust,mdinger/rust,SiegeLord/rust,kwantam/rust,jashank/rust,aepsil0n/rust,graydon/rust,avdi/rust,l0kod/rust,nwin/rust,ktossell/rust,mahkoh/rust,kmcallister/rust,michaelballantyne/rust-gpu,AerialX/rust,cllns/rust,aneeshusa/rust,pshc/rust,michaelballantyne/rust-gpu,AerialX/rust-rt-minimal,dwillmer/rust,victorvde/rust,carols10cents/rust,ktossell/rust,fabricedesre/rust,GBGamer/rust,pelmers/rust,TheNeikos/rust,vhbit/rust,nwin/rust,jroesch/rust,jashank/rust,KokaKiwi/rust,SiegeLord/rust,pshc/rust,pshc/rust,vhbit/rust,pczarn/rust,nwin/rust,dwillmer/rust,defuz/rust,aepsil0n/rust,KokaKiwi/rust,barosl/rust,avdi/rust,rprichard/rust,0x73/rust,AerialX/rust,andars/rust,richo/rust,untitaker/rust,KokaKiwi/rust,jbclements/rust,emk/rust,untitaker/rust,omasanori/rust,seanrivera/rust,nham/rust,mdinger/rust,LeoTestard/rust,kwantam/rust,zachwick/rust,graydon/rust,nwin/rust,miniupnp/rust,erickt/rust,ebfull/rand,servo/rust,avdi/rust,michaelballantyne/rust-gpu,nwin/rust,stepancheg/rust-ide-rust,kmcallister/rust,reem/rust,mvdnes/rust,jashank/rust,carols10cents/rust,kimroen/rust,kmcallister/rust,mvdnes/rust,bombless/rust,zubron/rust,sarojaba/rust-doc-korean,ruud-v-a/rust,bombless/rust,kimroen/rust,aepsil0n/rust,krzysz00/rust,kimroen/rust,ejjeong/rust,emk/rust,sarojaba/rust-doc-korean,seanrivera/rust,jashank/rust,P1start/rust,zubron/rust,gifnksm/rust,richo/rust,mdinger/rust,michaelballantyne/rust-gpu,defuz/rust,victorvde/rust,fabricedesre/rust,servo/rust,pczarn/rust,pelmers/rust,jbclements/rust,huonw/rand,hauleth/rust,mvdnes/rust,cllns/rust,graydon/rust,zachwick/rust,quornian/rust,ruud-v-a/rust,fabricedesre/rust,dwillmer/rust,sarojaba/rust-doc-korean,carols10cents/rust,jbclements/rust,reem/rust,0x73/rust,jroesch/rust,hauleth/rust,pczarn/rust,quornian/rust,sae-bom/rust,aepsil0n/rust,miniupnp/rust,seanrivera/rust,AerialX/rust-rt-minimal,GBGamer/rust,omasanori/rust,SiegeLord/rust,quornian/rust,philyoon/rust,GBGamer/rust,Ryman/rust,mvdnes/rust,fabricedesre/rust,XMPPwocky/rust,pelmers/rust,jbclements/rust,krzysz00/rust,TheNeikos/rust,philyoon/rust,aidancully/rust,andars/rust,jashank/rust,kwantam/rust,sae-bom/rust,dinfuehr/rust,emk/rust,rprichard/rust,fabricedesre/rust,nwin/rust,SiegeLord/rust,michaelballantyne/rust-gpu,gifnksm/rust,aturon/rust,pczarn/rust,l0kod/rust,robertg/rust,rohitjoshi/rust,sarojaba/rust-doc-korean,reem/rust,GBGamer/rust,andars/rust,KokaKiwi/rust,miniupnp/rust,GBGamer/rust,pczarn/rust,vhbit/rust,pelmers/rust,philyoon/rust,arthurprs/rand,stepancheg/rust-ide-rust,pelmers/rust,bombless/rust,barosl/rust,aidancully/rust,pythonesque/rust,avdi/rust,gifnksm/rust,aturon/rust,TheNeikos/rust,aneeshusa/rust,jashank/rust,philyoon/rust,aturon/rust,avdi/rust,defuz/rust,graydon/rust,pythonesque/rust,richo/rust,ktossell/rust,pczarn/rust,seanrivera/rust,bombless/rust,LeoTestard/rust,dinfuehr/rust,kimroen/rust,nwin/rust,zaeleus/rust,P1start/rust,dinfuehr/rust,l0kod/rust,gifnksm/rust,kwantam/rust,carols10cents/rust,graydon/rust,vhbit/rust,ebfull/rust,mdinger/rust,Ryman/rust,XMPPwocky/rust,mihneadb/rust,LeoTestard/rust,pshc/rust,mitsuhiko/rust,graydon/rust,reem/rust,stepancheg/rust-ide-rust,jashank/rust,pythonesque/rust,zubron/rust,stepancheg/rust-ide-rust,miniupnp/rust,krzysz00/rust,mitsuhiko/rust,zaeleus/rust,XMPPwocky/rust,GBGamer/rust,aidancully/rust,sae-bom/rust,servo/rust,pshc/rust,emk/rust,zachwick/rust,j16r/rust,ruud-v-a/rust,omasanori/rust,gifnksm/rust,servo/rust,TheNeikos/rust,kimroen/rust,mihneadb/rust,mvdnes/rust,untitaker/rust,mitsuhiko/rust,jbclements/rust,pshc/rust,j16r/rust,ruud-v-a/rust,GrahamDennis/rand,Ryman/rust,mahkoh/rust,mihneadb/rust,mahkoh/rust,nham/rust,jroesch/rust,j16r/rust,krzysz00/rust,jashank/rust,sae-bom/rust,mvdnes/rust,jroesch/rust,zaeleus/rust,KokaKiwi/rust,ejjeong/rust,jbclements/rust,richo/rust,pythonesque/rust,zaeleus/rust,omasanori/rust,aturon/rust