Bug 126173

Summary: [GTK][WK2] Simplify ProcessExecutablePathGtk
Product: WebKit Reporter: Zan Dobersek <zan>
Component: New BugsAssignee: Zan Dobersek <zan>
Status: RESOLVED FIXED    
Severity: Normal CC: betravis, cgarcia, commit-queue, esprehn+autocc, glenn, gyuyoung.kim, macpherson, menard, mrobinson
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Initial patch none

Description Zan Dobersek 2013-12-23 12:03:22 PST
[GTK][WK2] Simplify ProcessExecutablePathGtk
Comment 1 Zan Dobersek 2013-12-23 12:13:00 PST
Created attachment 219923 [details]
Patch
Comment 2 Martin Robinson 2013-12-23 12:29:27 PST
Comment on attachment 219923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=219923&action=review

> Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp:51
> +    static CString executablePath = getCurrentExecutablePath();
>      if (!executablePath.isNull()) {
> -        String processPath = pathByAppendingComponent(executablePath, processName);
> +        String processPath = pathByAppendingComponent(directoryName(filenameToString(executablePath.data())), processName);
>          if (fileExists(processPath))
>              return processPath;

This is a little slower, because directoryName and filenameToString runs for each path, but not much.
Comment 3 Zan Dobersek 2013-12-23 13:06:03 PST
Comment on attachment 219923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=219923&action=review

>> Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp:51
>>              return processPath;
> 
> This is a little slower, because directoryName and filenameToString runs for each path, but not much.

I can further store return values of findWebKitProcess in static variables in executablePathOf*Process. This would limit the number of times that findWebKitProcess is called to 3.

If that sounds OK I can upload a new patch.
Comment 4 Martin Robinson 2013-12-23 13:10:36 PST
(In reply to comment #3)
> (From update of attachment 219923 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=219923&action=review
> 
> >> Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp:51
> >>              return processPath;
> > 
> > This is a little slower, because directoryName and filenameToString runs for each path, but not much.
> 
> I can further store return values of findWebKitProcess in static variables in executablePathOf*Process. This would limit the number of times that findWebKitProcess is called to 3.
> 
> If that sounds OK I can upload a new patch.

It seems simpler to cache the return value of directoryName(filenameToString(...)), but if this function is called only a few times, I don't think it's a big deal.
Comment 5 Zan Dobersek 2013-12-23 13:21:51 PST
Comment on attachment 219923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=219923&action=review

>>>> Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp:51
>>>>              return processPath;
>>> 
>>> This is a little slower, because directoryName and filenameToString runs for each path, but not much.
>> 
>> I can further store return values of findWebKitProcess in static variables in executablePathOf*Process. This would limit the number of times that findWebKitProcess is called to 3.
>> 
>> If that sounds OK I can upload a new patch.
> 
> It seems simpler to cache the return value of directoryName(filenameToString(...)), but if this function is called only a few times, I don't think it's a big deal.

This will now be called whenever a new process is being created. It's unnecessary work, really.

I can offload all of this (getCurrentExecutablePath, filenameToString and directoryName calls) into a small helper static function. Its return value would then be stored in the static variable, so it would only get called once.
Comment 6 Zan Dobersek 2013-12-23 13:33:30 PST
Created attachment 219929 [details]
Patch
Comment 7 Zan Dobersek 2013-12-23 14:04:11 PST
Comment on attachment 219929 [details]
Patch

Clearing flags on attachment: 219929

Committed r161020: <http://trac.webkit.org/changeset/161020>
Comment 8 Zan Dobersek 2013-12-23 14:04:18 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Bear Travis 2014-01-09 12:55:44 PST
Reopening to attach new patch.
Comment 10 Bear Travis 2014-01-09 12:55:45 PST
Created attachment 220760 [details]
Initial patch
Comment 11 Martin Robinson 2014-01-09 13:14:15 PST
(In reply to comment #10)
> Created an attachment (id=220760) [details]
> Initial patch

Wrong bug?
Comment 12 Bear Travis 2014-01-09 23:28:28 PST
Yes, apologies. Was wondering where webkit-patch sent this one.