[MPlayer-dev-eng] Sample translation lookup implementation

Michael Niedermayer michaelni at gmx.at
Wed Dec 6 19:16:15 CET 2006


Hi

On Wed, Dec 06, 2006 at 06:58:33PM +0100, Michael Niedermayer wrote:
> Hi
> 
> On Wed, Dec 06, 2006 at 06:21:35PM +0200, Uoti Urpala wrote:
> > The patch implements a simple string-based translation lookup function.
> > The purpose is mainly to prove wrong the "complexity" claims about
> > string lookup and demonstrate that a simple implementation is enough to
> > give functionality superior to catgets or other integer-based lookup
> > schemes. The patch adds a simple translation lookup function and
> > demonstrates the functionality by trying to translate mp_msg() messages.
> > 
> > The translation file format used is safe against problems caused by
> > outdated translation files but not incorrect/malicious ones. It's not
> > completely platform-independent (depends on values of PRI* macros) but
> > should work enough to test on any platform.
> 
> some random comments (besides the already mentioned issues of using strings
> as keys)
> 1. the file is not editable by normal text editors (very serious flaw IMO)
> 2. it mixes spaces and tabs for indention (yeah iam fully aware that this
>    is mplayer-dev but still ...)
> 3. it mixes declaration and statements

and just to proof that string based systems are fundamentally inferior to
integer based ones (and iam not saying that my following suggestion is a
good idea just that it provides everything string-keys provide but at
significantly lower space and complexity)

simply replace every string by a unique integer, 64bit if needed, a simple
compare is O(1) instead of O(strlen), space too is 1 vs strlen, and its of
course simpler as its constant length

now how to assign integers so they are no conflicts?
random will do, its unlikely that a conflict will happen before we use
2^32 different messages and if thats not good enough then simply using
the IP address of whoever adds the message + the time or such would
gurantee that no conflicts can happen, and conflicts are trivial to
resolve anyway just detect and select another integer ...

the remaining differences are a question of the used tools ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali



More information about the MPlayer-dev-eng mailing list