On Wed Mar 18 09:54:54 EDT 2009, rogpe...@gmail.com wrote: > 2009/3/18 erik quanstrom <quans...@quanstro.net>: > > - ewd = wd+l+100-1; > > one small comment, based on a totally superficial scan of that diff: > might it not be better to grow the buffer by some multiplicative > factor, to avoid linear behaviour when reading large files? > i often (for no particularly good reason) use 50% as a growth > factor - it doesn't seem as radical as *2, but will still work ok > in the long run.
i have two arguments against doing expontential growth: - other dynamicly allocated buffers in rc are allocated in increments of 100 bytes. - the linear behavior would only be for long *tokens*. the length of the input is irrelavant. only in the case of tokens >= 100 chars would there be a second call to realloc. the total cost is O(maximum token length) for the whole input. how could this be a problem? - erik