Skip to content

Commit

Permalink
Merge pull request #543 from Arneball/master
Browse files Browse the repository at this point in the history
Not every access has to be synchronized, and return type should not be nullable.
  • Loading branch information
hannesa2 authored Nov 5, 2024
2 parents 47858ff + 0745ca3 commit 862add4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tracker/src/main/java/org/matomo/sdk/Matomo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ class Matomo private constructor(context: Context) {
private var sInstance: Matomo? = null

@JvmStatic
@Synchronized
fun getInstance(context: Context): Matomo? {
if (sInstance == null) {
synchronized(Matomo::class.java) { if (sInstance == null) sInstance = Matomo(context) }
fun getInstance(context: Context): Matomo {
return sInstance ?: synchronized(Matomo::class.java) {
sInstance ?: Matomo(context).also {
sInstance = it
}
}
return sInstance
}

@JvmStatic
Expand Down

0 comments on commit 862add4

Please sign in to comment.