Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Thoughts on function Date: Thu, 15 Sep 2011 17:08:16 +1200 Lines: 46 Message-ID: <9ddfi0F784U12@mid.individual.net> References: <19d88541-0f1e-4fa5-90dd-9ff8c23046f3@19g2000vbx.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net kNZAmDSyHzbxOHrTGU70Awm+DAeu3h1Q5vvkff2FjkIANSIj5I Cancel-Lock: sha1:byWtlJvNIujB6gSEr+vH3bSXvKs= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: <19d88541-0f1e-4fa5-90dd-9ff8c23046f3@19g2000vbx.googlegroups.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:10122 On 09/15/11 05:01 PM, Ebenezer wrote: > > Shalom > > How to improve this function? > > bool > SendBuffer::Flush () > { > uint32_t const all = buf_.size(); > uint32_t numWritten = 0; You're probably better off using size_t unless you have a really really good reason to use uint32_t. > if (partialFlush_) { > ::neolib::segmented_array::segment& > segment = > segmented_iterator chunk_size>(buf_.begin()).segment(); > > numWritten = Write(sock_,&buf_[0], segment.size()); Undeclared function again. > if (numWritten< segment.size()) goto ending; Ug. > partialFlush_ = false; Lots of undefined stuff there, so can't comment. > } > > { > int32_t const chunks = (all - numWritten) / chunk_size; > for (int32_t ii = 0; ii< chunks; ++ii) { > uint32_t bytes = Write(sock_,&buf_[numWritten], chunk_size); > numWritten += bytes; > if (bytes< chunk_size) goto ending; Ug, why on earth did you go and spoil it by using goto? -- Ian Collins