[haiku-gsoc] Re: locale kit patch : use haiku hash map instead of stl one.

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Tue, 21 Jul 2009 18:51:49 +0200

-------- Original-Nachricht --------
> Datum: Tue, 21 Jul 2009 16:55:02 +0200
> Von: Stephan Assmus <superstippi@xxxxxx>
> An: haiku-gsoc@xxxxxxxxxxxxx
> Betreff: [haiku-gsoc] Re: locale kit patch : use haiku hash map instead of 
> stl one.

> Hi Adrien,
> 
> On 2009-07-20 at 10:57:51 [+0200], PulkoMandy <pulkomandy@xxxxxxxxx>
> wrote:
> > Ok, got it working.
> > Also includes :
> > -More build fixes to tests
> > -Some style fixes
> 
> Just a general comment on the HashMap usage:
> 
> -     CatMap::const_iterator iter;
> -     for (iter = fCatMap.begin(); res == B_OK && iter != fCatMap.end(); 
> ++iter) {
> +     CatMap::Iterator iter = fCatMap.GetIterator();
> +     CatMap::Entry entry;
> +     while (res == B_OK && iter.HasNext()) {
>               archive.MakeEmpty();
> -             res = archive.AddString("c:ostr", iter->first.fString.String())
> -                     || archive.AddString("c:ctxt", 
> iter->first.fContext.String())
> -                     || archive.AddString("c:comt", 
> iter->first.fComment.String())
> -                     || archive.AddInt32("c:hash", iter->first.fHashVal)
> -                     || archive.AddString("c:tstr", iter->second.String());
> +             entry = iter.Next();
> +             res = archive.AddString("c:ostr", entry.key.fString.String())
> +                     || archive.AddString("c:ctxt", 
> entry.key.fContext.String())
> +                     || archive.AddString("c:comt", 
> entry.key.fComment.String())
> +                     || archive.AddInt32("c:hash", entry.key.fHashVal)
> +                     || archive.AddString("c:tstr", entry.value.String());
>               if (res == B_OK)
>                       res = archive.Flatten(dataIO);
>       }
> 
> 
> This code works fine,

It does, but logically or'ing error codes and comparing the result with B_OK 
definitely isn't good practice.

CU, Ingo

Other related posts: