diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-07-08 01:25:55 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 01:25:55 +0530 |
commit | 616992087846fe76555080baf131637924b67507 (patch) | |
tree | 3130913ac749c3d765af3a38aa13208fefbf6400 /app/src/main/java/mozilla/components | |
parent | 4657185dc6f161418ce7e8e4f9dd2976fc54427a (diff) |
global: set an import order rule and reformat with it (#924)
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/mozilla/components')
3 files changed, 4 insertions, 0 deletions
diff --git a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt index 6df3caca..0fb59002 100644 --- a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt +++ b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixList.kt @@ -31,6 +31,7 @@ class PublicSuffixList( dispatcher: CoroutineDispatcher = Dispatchers.IO, private val scope: CoroutineScope = CoroutineScope(dispatcher) ) { + private val data: PublicSuffixListData by lazy { PublicSuffixListLoader.load(context) } /** diff --git a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt index 0cbf6945..778e9fee 100644 --- a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt +++ b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt @@ -17,6 +17,7 @@ internal class PublicSuffixListData( private val rules: ByteArray, private val exceptions: ByteArray ) { + private fun binarySearchRules(labels: List<ByteArray>, labelIndex: Int): String? { return rules.binarySearch(labels, labelIndex) } @@ -147,6 +148,7 @@ internal class PublicSuffixListData( } companion object { + val WILDCARD_LABEL = byteArrayOf('*'.toByte()) val PREVAILING_RULE = listOf("*") val EMPTY_RULE = listOf<String>() diff --git a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt index 88e82523..65caeae5 100644 --- a/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt +++ b/app/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt @@ -14,6 +14,7 @@ import java.io.IOException private const val PUBLIC_SUFFIX_LIST_FILE = "publicsuffixes" internal object PublicSuffixListLoader { + fun load(context: Context): PublicSuffixListData = context.assets.open( PUBLIC_SUFFIX_LIST_FILE ).buffered().use { stream -> |