Skip to content

Commit

Permalink
Patch from Sean Farley:
Browse files Browse the repository at this point in the history
	Basically, the dirty trick I used here was to remove some pointer
	traversals in expensive spots.
  • Loading branch information
howardjp committed Feb 4, 2003
1 parent 96b7a4f commit 7bfdf54
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mmfile.c
Expand Up @@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mmfile.c,v 1.1 2002/09/14 16:30:18 howardjp Exp $
* $Id: mmfile.c,v 1.2 2003/02/04 03:04:50 howardjp Exp $
*/

#include <sys/param.h>
Expand Down Expand Up @@ -85,14 +85,16 @@ char *
mmfgetln(mmf_t *mmf, size_t *l)
{
static char *p;
char *start = mmf->ptr; // Remove speed bump
char *end = mmf->end; // Remove speed bump

if (mmf->ptr >= mmf->end)
if (start >= end)
return NULL;
for (p = mmf->ptr; mmf->ptr < mmf->end; ++mmf->ptr)
if (*mmf->ptr == '\n')
for (p = start; start < end; ++start)
if (*start == '\n')
break;
*l = mmf->ptr - p;
++mmf->ptr;
*l = start - p;
mmf->ptr = start + 1;
return p;
}

Expand Down

0 comments on commit 7bfdf54

Please sign in to comment.