Prevent wildcards from being accepted in filenames (NT mode)

Shachar Shemesh wine-devel at shemesh.biz
Thu Nov 27 00:38:21 CST 2003


Dmitry Timoshkov wrote:

>"Shachar Shemesh" <wine-patches at shemesh.biz> wrote:
>
>  
>
>>+    /* If wer'e in NT mode - don't allow wildcards in file name */
>>+    if( (strchrW(name, '?') || strchrW(name, '*')) && (GetVersion()&0x80000000)==0 )
>>    
>>
>
>(GetVersion() & 0x80000000)==0) construct is very inefficient. It forces
>compiler generate both a bit mask test and a comparison operation. While
>many modern processors have very effective bit test instructions, and
>we have to tell to the compiler that we want only a bit test.
>
>Simple !(GetVersion() & 0x80000000) is much better IMO.
>  
>
Alexandre and Dimi already answered the technical aspect. I will just 
mention that my stylistic preferences say that you should only use 
boolean operators on things that are conceptually boolean. Since C 
(unlike modern C++) doesn't have a bool type, that means merely 
referring to the BOOL type, and the result of boolean returning 
operators (==, &&, etc.).

In this case the test I wish to make is "is the uppermost bit clear?", 
and that translates to "(blah & 0x80000000)==0". It was not boolean 
before the operator, and & is not a boolean operator.

Now, this is not an attempt to force my style on anyone else. I do not 
intend this to become a religious war. This is just the rational behind 
my style. While I will be happy to hear Dimi's rational for his, I don't 
think there is much room for an actual "discussion", as these things 
tend to turn into religious flame wars.

             Shachar

P.S.
A good exam, I think, to see whether your reply is presenting your own 
style or is an argument is to see whether your reply relies on my reply. 
If Dimi says "I do that because....", that's a reply, while if he says 
"My way is better because...", it's probably an argument.

-- 
Shachar Shemesh
Open Source integration & consulting
Home page & resume - http://www.shemesh.biz/





More information about the wine-devel mailing list