Subject: Re: PR/33392 CVS commit: src/dist/nawk
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,>
From: Aleksey Cheusov <cheusov@tut.by>
List: netbsd-bugs
Date: 07/26/2006 21:20:03
The following reply was made to PR bin/33392; it has been noted by GNATS.
From: Aleksey Cheusov <cheusov@tut.by>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: PR/33392 CVS commit: src/dist/nawk
Date: Thu, 27 Jul 2006 00:23:14 +0300
> | Are you sure about the following?
> |
> | @@ -82,10 +82,10 @@
> | void *p;
> | int i, new_count;
> |
> | - if (state < fa->state_count)
> | + if (++state < fa->state_count)
> | return
> |
> | I think ++ is unwanted
> |
> | new_count = state + 10;
> | for (i = fa->state_count; i < new_count; ++i) {
> | ^^^^^
> | ...
> | }
> | fa->state_count = new_count;
>
> The meaning of state_count has changed from being the largest number
> allocated to be the count of the states allocated, so both are correct.
> The code now passes all the regression tests. We could change the
> ++state, if we change the resize_state calls to be 1 greater than now,
> but that is more intrusive.
You are right, both are correct.
Suppose
1) we are here
918 /* add tmpset to current set of states */
919 ++(f->curstat);
+ 920 resize_state(f, f->curstat);
921 for (i = 0; i < NCHARS; i++)
2) 100 states was already created and all tables was properly initialized, i.e.
f->state_count == 2.
3) f->curstat == 99
1) + 2) + 3) ===> unnecessary memory allocation in resize_state(), just a few kbytes.
Is there any reason for this?
--
Best regards, Aleksey Cheusov.