Re: RFC: getting a unique integer value


Subject: Re: RFC: getting a unique integer value
From: Dom Lachowicz (dominicl@seas.upenn.edu)
Date: Mon Oct 15 2001 - 08:33:47 CDT


Quoting Mike Nordell <tamlin@algonet.se>:

> I agree with Hub here. If we are to get unique numbers used as IDs for
> something, anything, why not use an incrementing ID? Random numbers
> (even
> that this is no RNG, it's like most implementations a PRNG) are used for
> quite different purposes. We don't really _need_ random numbers, do we?
> Isn't what we actually need unique IDs, or?

Seriously... We don't need random numbers here, just unique ones. Here's my
proposed replacement, which is also a helluva lot faster than any known good
random number generator:

UT_uint32 UT_newNumber ()
{
  static UT_uint32 theNum = 0;
  //MUTEX_PROTECT this variable someday soon
  return theNum++;
}

Anyone opposed to me checking this into ut_math?

Dom



This archive was generated by hypermail 2b25 : Mon Oct 15 2001 - 08:33:55 CDT