[comp.windows.x] XGetDefaults bug

tsf@theory.cs.cmu.edu (Timothy Freeman) (06/27/87)

XGetDefaults has a known bug which is that it ignores its first
parameter every time it is called except the first.  Does anyone have
a fix for this?  If I don't get a response, I'll fix it myself in a
couple of days and post the result here.

How do people feel about posting bug fixes here in general?  I think
it is a reasonable thing to do, because I think it is of interest to
the people who read this group.  
-- 
Tim Freeman

Arpanet: tsf@theory.cs.cmu.edu
Uucp:    ...!seismo!theory.cs.cmu.edu!tsf

wyatt@cfa.harvard.EDU (Bill Wyatt) (07/06/87)

> XGetDefaults has a known bug which is that it ignores its first
> parameter every time it is called except the first.  [...]

Hasn't this come up before? Anyway, it's not a bug, but a feature. The
entire .Xdefaults file is scanned and stored as a b-tree, and subsequent
calls do not re-read the file, making accesses MUCH faster. 

I admit that sometimes you want to change the first argument and look
for a different parameter, but that is really a different sort of
function than what XGetDefaults was designed to perform. 

In any case, the resource management stuff in v11 will address the problem,
as I understand it.
-- 

Bill    UUCP:  {seismo|ihnp4}!harvard!cfa!wyatt
Wyatt   ARPA:  wyatt@cfa.harvard.edu
         (or)  wyatt%cfa@harvard.harvard.edu
      BITNET:  wyatt@cfa2
        SPAN:  17410::wyatt   (this will change in June)

tsf@theory.cs.cmu.edu (Timothy Freeman) (07/07/87)

In article <613@cfa.cfa.harvard.EDU> wyatt@cfa.harvard.EDU (Bill Wyatt) writes:
>Hasn't this come up before? Anyway, it's not a bug, but a feature. The
>entire .Xdefaults file is scanned and stored as a b-tree, and subsequent
>calls do not re-read the file, making accesses MUCH faster. 

It is a bug, because the manual doesn't describe the true behavior of
the routine accurately.

Your comment implies that the bug allows XGetDefault to perform
better.  That isn't true, because XGetDefault could have re-read the
.Xdefaults file each time the first parameter changed.  This would
have resulted in the same performance in the cases where the old
XGetDefault routine was correct, and correct results in all cases.

The version I posted reads the entire .Xdefaults file (including the
lines which appply to irrelevant programs) into the b-tree the first
time XGetDefault is called, and it looks in the tree every time after
the first.  Since every line in the file is represented in the tree,
this yields correct behavior (assuming that the file doesn't change).

How about if you send me net mail if you want to argue about this,
since there probably aren't many people on the net interested in
reading our argument?
-- 
Tim Freeman

Arpanet: tsf@theory.cs.cmu.edu
Uucp:    ...!seismo!theory.cs.cmu.edu!tsf