WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
168913
Optimize checkWebRTCAvailability
https://bugs.webkit.org/show_bug.cgi?id=168913
Summary
Optimize checkWebRTCAvailability
Alex Christensen
Reported
2017-02-27 08:44:37 PST
Optimize checkWebRTCAvailability
Attachments
Patch
(1.96 KB, patch)
2017-02-27 08:47 PST
,
Alex Christensen
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2017-02-27 08:47:03 PST
Created
attachment 302843
[details]
Patch
Darin Adler
Comment 2
2017-02-27 09:20:02 PST
Comment on
attachment 302843
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=302843&action=review
> Source/WebKit2/UIProcess/WebPreferences.cpp:213 > + static bool available = false; > + static std::once_flag once; > + std::call_once(once, [&]() { > + void* libwebrtcLibrary = dlopen("libwebrtc.dylib", RTLD_LAZY); > + if (!libwebrtcLibrary) { > + available = false; > + return; > + } > + dlclose(libwebrtcLibrary); > + available = true; > + }); > + return available;
Does this need to be called from arbitrary threads? If not, then I suggest just using global variable initialization rather than call_once. static bool available = [] { auto library = dlopen("libwebrtc.dylib", RTLD_LAZY); if (!library) return false; dlclose(library); return true; }(); return available; Fewer lines of code, also slightly more efficient.
Alex Christensen
Comment 3
2017-02-27 09:23:57 PST
http://trac.webkit.org/r213074
mitz
Comment 4
2017-02-27 09:33:45 PST
This check can be implemented by null-checking any of the symbols known to be exported from the dylib, which is a single branch. An implementation that involves a function call still seems unoptimal.
Darin Adler
Comment 5
2017-02-28 16:59:12 PST
(In reply to
comment #4
)
> This check can be implemented by null-checking any of the symbols known to > be exported from the dylib, which is a single branch. An implementation that > involves a function call still seems unoptimal.
We should do that instead!
Jon Lee
Comment 6
2017-03-03 14:00:29 PST
Filed follow-up
bug 169147
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug