MAMEWorld >> EmuChat
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

krick
Get Fuzzy
Reged: 02/09/04
Posts: 4235
Send PM
Re: bug: chdman output depends on system qsort() implementation
06/18/12 04:08 AM


> There's nothing wrong with using an arbitrary field to break ties as long as the
> value of that field is stable. The order of equal elements is ultimately irrelevant,
> so any stable ordering solution is as good as any other.

What I meant is that (unless I'm misunderstanding his code), he's temporarily stuffing curcode into m_bits (which is not being used yet) so that he can get at it to use as a tie breaker inside the qsort compare...

m_huffnode[curcode].m_bits = curcode;

Then he later sets m_bits back to 0 after the sort...

node.m_bits = 0;


Essentially, he's hijacking an existing member of the node object and storing something else in it temporarily, which is fine, but it just seems like something that could be confusing if it wasn't documented clearly. That's why I suggested that there might be another way to do it that didn't involve hijacking m_bits. Unfortunately, I can't think of one.

At the points where m_bits is being set and later cleared aren't right before and after the sort, so unless you already understand what's going on, I don't think it would make much sense. And if you look inside the comparison function, it appears that m_bits is being compared between the two nodes, but actually the curcode for each node is being compared, it's just stored in m_bits.


GroovyMAME support forum on BYOAC







Entire thread
Subject Posted by Posted on
* bug: chdman output depends on system qsort() implementation jmak 06/16/12 12:55 PM
. * Re: bug: chdman output depends on system qsort() implementation R. Belmont  06/16/12 03:56 PM
. * Re: bug: chdman output depends on system qsort() implementation krick  06/16/12 04:16 PM
. * Re: bug: chdman output depends on system qsort() implementation R. Belmont  06/16/12 05:50 PM
. * Re: bug: chdman output depends on system qsort() implementation krick  06/16/12 06:28 PM
. * Re: bug: chdman output depends on system qsort() implementation R. Belmont  06/16/12 06:39 PM
. * Re: bug: chdman output depends on system qsort() implementation italieAdministrator  06/16/12 08:38 PM
. * Re: bug: chdman output depends on system qsort() implementation jmak  06/16/12 08:22 PM
. * Re: bug: chdman output depends on system qsort() implementation krick  06/17/12 07:38 PM
. * Re: bug: chdman output depends on system qsort() implementation jmak  06/17/12 07:44 PM
. * Re: bug: chdman output depends on system qsort() implementation R. Belmont  06/17/12 10:13 PM
. * Re: bug: chdman output depends on system qsort() implementation AaronGiles  06/17/12 11:37 PM
. * Re: bug: chdman output depends on system qsort() implementation krick  06/18/12 04:08 AM
. * Re: bug: chdman output depends on system qsort() implementation R. Belmont  06/16/12 10:13 PM
. * Re: bug: chdman output depends on system qsort() implementation jmak  06/17/12 06:47 PM
. * Re: bug: chdman output depends on system qsort() implementation jmak  06/17/12 06:58 PM
. * Re: bug: chdman output depends on system qsort() implementation R. Belmont  06/17/12 10:00 PM
. * Re: bug: chdman output depends on system qsort() implementation jmak  06/19/12 09:30 PM
. * Re: bug: chdman output depends on system qsort() implementation AaronGiles  06/17/12 02:09 AM
. * Re: bug: chdman output depends on system qsort() implementation TafoidAdministrator  06/16/12 09:06 PM
. * Re: bug: chdman output depends on system qsort() implementation krick  06/16/12 08:10 PM
. * Re: bug: chdman output depends on system qsort() implementation jmak  06/16/12 08:33 PM

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 554 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2164