2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] No issue: remove inline from StrictModeManager.resetAfter.

I believe this was a premature optimization: it's unclear that it would
actually improve performance and yet  we had to add several weird
workarounds to make it work that broke encapsulation. It's also
possible it would be worse for the APK size because of excessive
inlining.
This commit is contained in:
Michael Comella 2020-10-07 10:16:46 -07:00 committed by Michael Comella
parent 9f2237e6f1
commit d23a1b8274

View File

@ -23,6 +23,9 @@ import org.mozilla.fenix.perf.Performance
private const val MANUFACTURE_HUAWEI: String = "HUAWEI" private const val MANUFACTURE_HUAWEI: String = "HUAWEI"
private const val MANUFACTURE_ONE_PLUS: String = "OnePlus" private const val MANUFACTURE_ONE_PLUS: String = "OnePlus"
private val logger = Performance.logger
private val mainLooper = Looper.getMainLooper()
/** /**
* Manages strict mode settings for the application. * Manages strict mode settings for the application.
*/ */
@ -32,16 +35,10 @@ class StrictModeManager(
// Ideally, we'd pass in a more specific value but there is a circular dependency: StrictMode // Ideally, we'd pass in a more specific value but there is a circular dependency: StrictMode
// is passed into Core but we'd need to pass in Core here. Instead, we take components and later // is passed into Core but we'd need to pass in Core here. Instead, we take components and later
// fetch the value we need from it. // fetch the value we need from it.
// private val components: Components
// Public to be accessible by inline functions.
val components: Components
) { ) {
val logger = Performance.logger // public to be accessible by inline functions. private val isEnabledByBuildConfig = config.channel.isDebug
val mainLooper = Looper.getMainLooper() // public to be accessible by inline functions.
// This is public so it can be used by inline functions.
val isEnabledByBuildConfig = config.channel.isDebug
/** /**
* The number of times StrictMode has been suppressed. StrictMode can be used to prevent main * The number of times StrictMode has been suppressed. StrictMode can be used to prevent main
@ -114,7 +111,7 @@ class StrictModeManager(
* *
* @return the value returned by [functionBlock]. * @return the value returned by [functionBlock].
*/ */
inline fun <R> resetAfter(policy: StrictMode.ThreadPolicy, functionBlock: () -> R): R { fun <R> resetAfter(policy: StrictMode.ThreadPolicy, functionBlock: () -> R): R {
// Calling resetAfter takes 1-2ms (unknown device) so we only execute it if StrictMode can // Calling resetAfter takes 1-2ms (unknown device) so we only execute it if StrictMode can
// actually be enabled. https://github.com/mozilla-mobile/fenix/issues/11617 // actually be enabled. https://github.com/mozilla-mobile/fenix/issues/11617
return if (isEnabledByBuildConfig) { return if (isEnabledByBuildConfig) {