Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Malcolm McLean Newsgroups: comp.lang.c Subject: Re: filling area by color atack safety Date: Tue, 19 Mar 2024 12:06:13 +0000 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <20240317182520.00002390@yahoo.com> <20240317193908.00002634@yahoo.com> <86le6fo09e.fsf@linuxsc.com> <86wmpyn44y.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 19 Mar 2024 12:06:13 -0000 (UTC) Injection-Info: dont-email.me; posting-host="7afaabf9fdb4883652af28e583b6382d"; logging-data="866727"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zVaWDK9is5yWm52vxCT2XlSu9d5NCP/E=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:3bRjUqH3oILXyQ7hxmgp/8yS3iQ= Content-Language: en-GB In-Reply-To: <86wmpyn44y.fsf@linuxsc.com> Bytes: 2509 On 19/03/2024 06:10, Tim Rentsch wrote: > Malcolm McLean writes: > >> On 18/03/2024 18:36, Tim Rentsch wrote: >>> >>> >>> It doesn't scale well. In particular worst case performance >>> scaling is worse than O(N) (as determined experimentally, not >>> theoretically). >> >> Is that because the queue is being memmoved instead of using a >> circular buffer when it gets towards the end? > > I'm sure I don't know, and I'm astonished that you would ask. > It's your code after all. IMO it should simply be thrown out and > re-written; it pains me just to look at it, let alone to try to > understand or fix it. Yes, but I wrote it years ago. I can't remember why the value of 256 pixels was put in. But I do remember why the queue isn't very efficient - for the small images I expected to be processed, I judged that the added complexity of maintaining a circular queue wouldn't be worth it, given that I wanted the routine to be leaf. However if you can somehow trigger catastrophic big O behaviour, it won't be a surprise. -- Check out Basic Algorithms and my other books: https://www.lulu.com/spotlight/bgy1mm