GncBusiness v. GNCSession
Derek Atkins
warlord@MIT.EDU
23 Nov 2001 18:30:51 -0500
linas@linas.org (Linas Vepstas) writes:
> Right.
>
> After the change, it will be legal (probably; I will not test) to
> run gnucash with no active session. (but I will not intientionally
> make this so/break anything). It might someday become possible
> to have multiple sessions going for one book, although this has
> certain conceptual problems ....
Fair enough...
> > I have no problem with the GNCEntityTable living in the GNCBook
> > instead of the GNCSession. In fact, I think I'd like to extend the
> > GNCEntityTable to be able to handle arbitrary objects instead of the
> > hardcoded list of types.
>
> No objection, but lets look at the details...
>
> > In particular, this means that we would need to change the GNCIdType
> > enum and all the GNCEntity interfaces, or somehow be able to register
> > new GNCIdTypes. Personally I'd like to be able to use arbitrary
> > strings, or better yet, have a separate GHashTable for each entity.
> > Is there a preference?
>
> Not at the moment. I am *always* concerned about performance.
Fair enough. Looking at the implementation I don't think it
would affect speed that much to change the IdType to a char*.
Indeed, the IdType is just used as a verification on object type.
The fact that a strcmp() is slower than an integer comparison implies
that anything I do will be slower, unless we depend upon each object
module to supply its own (unique) integral IdType number. All we
could do at that point is provide a dual hash-table; one hash table
with the guid as the key, and one hash table to verify that an IdType
is valid (the IdTypes being part of the registration process).
If we're willing to live with a strcmp() then the change isn't a
problem at all, but it _would_ add a strcmp() for every
xaccFooLookup() performed. How much time do we currently spend in the
Lookup() functions and will this extra strcmp() really affect it that
much?
The alternative, one Hash per object, would require an extra hashtable
lookup, which most likely implies an extra strcmp() as well.
> --linas
-derek
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord@MIT.EDU PGP key available