From: markus schnalke Date: Thu, 22 Mar 2012 20:27:53 +0000 (+0100) Subject: scansbr: Removed the ``performance hack'' for inc as it wasn't faster. X-Git-Tag: mmh-thesis-end~229 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=d7b4f0034bc4f5b5c2f990d0984858e9b6f4131a;p=mmh scansbr: Removed the ``performance hack'' for inc as it wasn't faster. I tested a 150MB/500msgs mbox but couldn't see any time differences. In both cases it took 2-5s on my machine. Hence, I go for the much simpler and not ``we use strange internals'' version. If you really inc much larger mboxes, then just take some time. ;-) The explaining comment for the hack had been: Performance hack: some people like to run "inc" on things like net.sources or large digests. We do a copy directly into the output buffer rather than going through an intermediate buffer. We need the amount of data m_getfld found & don't want to do a strlen on the long buffer so there's a hack in m_getfld to save the amount of data it returned in the global "msg_count". --- diff --git a/uip/scansbr.c b/uip/scansbr.c index 299027a..7dedf70 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -219,41 +219,11 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, } FPUTS("\n"); FPUTS(tmpbuf); - /* - ** performance hack: some people like to run "inc" - ** on things like net.sources or large digests. - ** We do a copy directly into the output buffer - ** rather than going through an intermediate buffer. - ** - ** We need the amount of data m_getfld found & - ** don't want to do a strlen on the long buffer so - ** there's a hack in m_getfld to save the amount - ** of data it returned in the global "msg_count". - */ body:; while (state == BODY) { -#ifdef LINUX_STDIO - if (scnout->_IO_write_ptr == scnout->_IO_write_end) { -#elif defined(__DragonFly__) - if (((struct __FILE_public *)scnout)->_w <= 0) { -#else - if (scnout->_cnt <= 0) { -#endif - if (fflush(scnout) == EOF) - adios(scnmsg, "write error on"); - } -#ifdef LINUX_STDIO - state = m_getfld(state, name, scnout->_IO_write_ptr, (long)scnout->_IO_write_ptr-(long)scnout->_IO_write_end , inb); - scnout->_IO_write_ptr += msg_count; -#elif defined(__DragonFly__) - state = m_getfld(state, name, ((struct __FILE_public *)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb); - ((struct __FILE_public *)scnout)->_w -= msg_count; - ((struct __FILE_public *)scnout)->_p += msg_count; -#else - state = m_getfld(state, name, scnout->_ptr, -(scnout->_cnt), inb); - scnout->_cnt -= msg_count; - scnout->_ptr += msg_count; -#endif + state = m_getfld(state, name, tmpbuf, SBUFSIZ, + inb); + FPUTS(tmpbuf); } goto finished;