Closed Bug 726576 Opened 12 years ago Closed 12 years ago

Optimize calls to nsLocalFileWin's HasFileAttribute

Categories

(Core :: XPCOM, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: bbondy, Assigned: bbondy)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Patch v1. (obsolete) — Splinter Review
HasFileAttribute does 2 calls to get the file attributes, one from ResolveAndStat and the other from GetFileAttributesW right after it.
This can be optimized to do only one by using Resolve instead.

Also this function doesn't check for INVALID_FILE_ATTRIBUTES so if ResolveAndStat was not dirty, and the state changed so the file got deleted, this function would return incorrect results before. 

Also the code in IsFile and IsDirectory can be simplified as Neil suggested previously to use HasFileAttribute instead.
Attachment #596670 - Flags: review?(neil)
Comment on attachment 596670 [details] [diff] [review]
Patch v1.

>-  if (INVALID_FILE_ATTRIBUTES == attributes) {
Bah, I hadn't noticed that you like your comparisons the wrong way around ;-)

>+    DWORD attributes = GetFileAttributesW(mResolvedPath.get());
::GetFileAttributesW ?
Attachment #596670 - Flags: review?(neil) → review+
> Bah, I hadn't noticed that you like your comparisons the wrong way around ;-)

I'm pretty indifferent about it but I've been asked to switch it after some review comments so I just start off that way usually now :)

> ::GetFileAttributesW ?

I think we're moving away from ::, but if you want I can do it.
and by we I mean me :)
Attached patch Patch v2.Splinter Review
Returned converted windows error code instead of always returning invalid path since it was causing try failures. Carrying forward r+.
Attachment #596670 - Attachment is obsolete: true
Attachment #598221 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/52917f8cfc41
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: