diff --git a/README.md b/README.md index c30d5c228eb..c1227b8b088 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ Add it in your root `build.gradle` at the end of repositories. allprojects { repositories { jcenter() - maven { url 'https://jitpack.io' } } } ``` diff --git a/build.gradle b/build.gradle index d98433a7c3f..ea486ebd751 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,6 @@ buildscript { repositories { jcenter() - maven { url 'https://jitpack.io' } maven { url "http://dl.bintray.com/kotlin/kotlin-dev" } maven { url "https://dl.bintray.com/jetbrains/markdown/" } maven { url "https://dl.bintray.com/arrow-kt/arrow-kt/" } @@ -73,7 +72,6 @@ allprojects { maven { url "http://dl.bintray.com/kotlin/kotlin-dev" } maven { url "http://dl.bintray.com/arrow-kt/arrow-kt" } maven { url "https://dl.bintray.com/jetbrains/markdown/" } - maven { url 'https://jitpack.io' } } } diff --git a/modules/core/arrow-annotations-processor/build.gradle b/modules/core/arrow-annotations-processor/build.gradle index 044415eb507..fde9bbfc911 100644 --- a/modules/core/arrow-annotations-processor/build.gradle +++ b/modules/core/arrow-annotations-processor/build.gradle @@ -11,7 +11,6 @@ dependencies { exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect' } compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" - compile 'com.github.aballano:MnemoniK:1.0.0' compileOnly 'com.google.auto.service:auto-service:1.0-rc4' kapt 'com.google.auto.service:auto-service:1.0-rc4' diff --git a/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/internal/memoization.kt b/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/internal/memoization.kt new file mode 100644 index 00000000000..b307d0db6fd --- /dev/null +++ b/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/internal/memoization.kt @@ -0,0 +1,37 @@ +package arrow.meta.internal + +import java.util.concurrent.ConcurrentHashMap + +fun ((P1) -> R).memoize(): (P1) -> R = object : (P1) -> R { + private val m = MemoizedHandler<((P1) -> R), MemoizeKey1, R>(this@memoize) + override fun invoke(p1: P1) = m(MemoizeKey1(p1)) +} + +private interface MemoizedCall { + operator fun invoke(f: F): R +} + +private data class MemoizeKey1(val p1: P1) : MemoizedCall<(P1) -> R, R> { + override fun invoke(f: (P1) -> R) = f(p1) +} + +private class MemoizedHandler, out R>(val f: F) { + private val m = Platform.newConcurrentMap() + operator fun invoke(k: K): R = m[k] ?: run { m.putSafely(k, k(f)) } +} + +object Platform { + + interface ConcurrentMap : MutableMap { + fun putSafely(k: K, v: V): V + } + + fun newConcurrentMap(): ConcurrentMap { + val map by lazy { ConcurrentHashMap() } + return object : ConcurrentMap, MutableMap by map { + override fun putSafely(k: K, v: V): V = + map.putIfAbsent(k, v) ?: v + } + } + +} diff --git a/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/processor/MetaProcessor.kt b/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/processor/MetaProcessor.kt index 2e2613e2e4a..e2d814f581f 100644 --- a/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/processor/MetaProcessor.kt +++ b/modules/core/arrow-annotations-processor/src/main/java/arrow/meta/processor/MetaProcessor.kt @@ -1,6 +1,5 @@ package arrow.meta.processor -import aballano.kotlinmemoization.memoize import arrow.common.utils.AbstractProcessor import arrow.common.utils.ClassOrPackageDataWrapper import arrow.common.utils.ProcessorUtils @@ -8,6 +7,7 @@ import arrow.common.utils.knownError import arrow.meta.ast.Type import arrow.meta.ast.TypeName import arrow.meta.encoder.jvm.JvmMetaApi +import arrow.meta.internal.memoize import arrow.meta.processor.MetaProcessor.AnnotatedElement import com.squareup.kotlinpoet.FileSpec import me.eugeniomarletti.kotlin.metadata.KotlinMetadataUtils diff --git a/modules/docs/arrow-docs/docs/docs/README.md b/modules/docs/arrow-docs/docs/docs/README.md index e536913cb69..7eec7b3a360 100644 --- a/modules/docs/arrow-docs/docs/docs/README.md +++ b/modules/docs/arrow-docs/docs/docs/README.md @@ -169,19 +169,6 @@ Add the dependencies that you want to use ## Enabling kapt -Add to your pom.xml file the following repository: -``` - - - - false - - jitpack - https://jitpack.io - - -``` - Enable annotaton processing using kotlin plugin ```