400 lines
10 KiB
Smali
400 lines
10 KiB
Smali
.class public abstract Lcom/discord/utilities/frecency/FrecencyTracker;
|
|
.super Ljava/lang/Object;
|
|
.source "FrecencyTracker.kt"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T:",
|
|
"Ljava/lang/Object;",
|
|
">",
|
|
"Ljava/lang/Object;"
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public transient dirty:Z
|
|
|
|
.field public final history:Ljava/util/HashMap;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/util/HashMap<",
|
|
"TT;",
|
|
"Ljava/util/List<",
|
|
"Ljava/lang/Long;",
|
|
">;>;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
.field public final maxSamples:I
|
|
|
|
.field public final minScoreThreshold:I
|
|
|
|
.field public transient sortedKeys:Ljava/util/List;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/util/List<",
|
|
"+TT;>;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(II)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
iput p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->minScoreThreshold:I
|
|
|
|
iput p2, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->maxSamples:I
|
|
|
|
new-instance p1, Ljava/util/HashMap;
|
|
|
|
invoke-direct {p1}, Ljava/util/HashMap;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
const/4 p1, 0x1
|
|
|
|
iput-boolean p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->dirty:Z
|
|
|
|
sget-object p1, Lb0/i/l;->d:Lb0/i/l;
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->sortedKeys:Ljava/util/List;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static final synthetic access$getHistory$p(Lcom/discord/utilities/frecency/FrecencyTracker;)Ljava/util/HashMap;
|
|
.locals 0
|
|
|
|
iget-object p0, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method private final computeScores(J)V
|
|
.locals 5
|
|
|
|
new-instance v0, Ljava/util/HashMap;
|
|
|
|
iget-object v1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v1}, Ljava/util/HashMap;->size()I
|
|
|
|
move-result v1
|
|
|
|
invoke-direct {v0, v1}, Ljava/util/HashMap;-><init>(I)V
|
|
|
|
iget-object v1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
invoke-interface {v1}, Ljava/util/Map;->entrySet()Ljava/util/Set;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v1
|
|
|
|
:goto_0
|
|
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_1
|
|
|
|
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/util/Map$Entry;
|
|
|
|
invoke-interface {v2}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-interface {v2}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/util/List;
|
|
|
|
invoke-virtual {p0, v2, p1, p2}, Lcom/discord/utilities/frecency/FrecencyTracker;->computeScore(Ljava/util/List;J)I
|
|
|
|
move-result v2
|
|
|
|
iget v4, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->minScoreThreshold:I
|
|
|
|
if-le v2, v4, :cond_0
|
|
|
|
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-interface {v0, v3, v2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-interface {v1}, Ljava/util/Iterator;->remove()V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
invoke-virtual {v0}, Ljava/util/HashMap;->keySet()Ljava/util/Set;
|
|
|
|
move-result-object p1
|
|
|
|
const-string p2, "scores.keys"
|
|
|
|
invoke-static {p1, p2}, Lb0/n/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
new-instance p2, Lcom/discord/utilities/frecency/FrecencyTracker$computeScores$1;
|
|
|
|
invoke-direct {p2, p0, v0}, Lcom/discord/utilities/frecency/FrecencyTracker$computeScores$1;-><init>(Lcom/discord/utilities/frecency/FrecencyTracker;Ljava/util/HashMap;)V
|
|
|
|
invoke-static {p1, p2}, Lb0/i/f;->sortedWith(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->sortedKeys:Ljava/util/List;
|
|
|
|
const/4 p1, 0x0
|
|
|
|
iput-boolean p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->dirty:Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static synthetic getSortedKeys$default(Lcom/discord/utilities/frecency/FrecencyTracker;JILjava/lang/Object;)Ljava/util/Collection;
|
|
.locals 0
|
|
|
|
if-nez p4, :cond_1
|
|
|
|
and-int/lit8 p3, p3, 0x1
|
|
|
|
if-eqz p3, :cond_0
|
|
|
|
invoke-static {}, Lcom/discord/utilities/time/ClockFactory;->get()Lcom/discord/utilities/time/Clock;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-interface {p1}, Lcom/discord/utilities/time/Clock;->currentTimeMillis()J
|
|
|
|
move-result-wide p1
|
|
|
|
:cond_0
|
|
invoke-virtual {p0, p1, p2}, Lcom/discord/utilities/frecency/FrecencyTracker;->getSortedKeys(J)Ljava/util/Collection;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:cond_1
|
|
new-instance p0, Ljava/lang/UnsupportedOperationException;
|
|
|
|
const-string p1, "Super calls with default arguments not supported in this target, function: getSortedKeys"
|
|
|
|
invoke-direct {p0, p1}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static synthetic track$default(Lcom/discord/utilities/frecency/FrecencyTracker;Ljava/lang/Object;JILjava/lang/Object;)V
|
|
.locals 0
|
|
|
|
if-nez p5, :cond_1
|
|
|
|
and-int/lit8 p4, p4, 0x2
|
|
|
|
if-eqz p4, :cond_0
|
|
|
|
invoke-static {}, Lcom/discord/utilities/time/ClockFactory;->get()Lcom/discord/utilities/time/Clock;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-interface {p2}, Lcom/discord/utilities/time/Clock;->currentTimeMillis()J
|
|
|
|
move-result-wide p2
|
|
|
|
:cond_0
|
|
invoke-virtual {p0, p1, p2, p3}, Lcom/discord/utilities/frecency/FrecencyTracker;->track(Ljava/lang/Object;J)V
|
|
|
|
return-void
|
|
|
|
:cond_1
|
|
new-instance p0, Ljava/lang/UnsupportedOperationException;
|
|
|
|
const-string p1, "Super calls with default arguments not supported in this target, function: track"
|
|
|
|
invoke-direct {p0, p1}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public abstract computeScore(Ljava/util/List;J)I
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/util/List<",
|
|
"Ljava/lang/Long;",
|
|
">;J)I"
|
|
}
|
|
.end annotation
|
|
.end method
|
|
|
|
.method public final getMaxSamples()I
|
|
.locals 1
|
|
|
|
iget v0, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->maxSamples:I
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public final getMinScoreThreshold()I
|
|
.locals 1
|
|
|
|
iget v0, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->minScoreThreshold:I
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public final declared-synchronized getSortedKeys(J)Ljava/util/Collection;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(J)",
|
|
"Ljava/util/Collection<",
|
|
"TT;>;"
|
|
}
|
|
.end annotation
|
|
|
|
monitor-enter p0
|
|
|
|
:try_start_0
|
|
iget-boolean v0, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->dirty:Z
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-direct {p0, p1, p2}, Lcom/discord/utilities/frecency/FrecencyTracker;->computeScores(J)V
|
|
|
|
:cond_0
|
|
iget-object p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->sortedKeys:Ljava/util/List;
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
monitor-exit p0
|
|
|
|
return-object p1
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
monitor-exit p0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public final declared-synchronized removeEntry(Ljava/lang/Object;)V
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(TT;)V"
|
|
}
|
|
.end annotation
|
|
|
|
monitor-enter p0
|
|
|
|
:try_start_0
|
|
iget-object v0, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
const/4 p1, 0x1
|
|
|
|
iput-boolean p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->dirty:Z
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
monitor-exit p0
|
|
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
monitor-exit p0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public final declared-synchronized track(Ljava/lang/Object;J)V
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(TT;J)V"
|
|
}
|
|
.end annotation
|
|
|
|
monitor-enter p0
|
|
|
|
:try_start_0
|
|
iget-object v0, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, Ljava/util/List;
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
sget-object v0, Lb0/i/l;->d:Lb0/i/l;
|
|
|
|
:goto_0
|
|
invoke-static {p2, p3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-static {v0, p2}, Lb0/i/f;->plus(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object p2
|
|
|
|
iget p3, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->maxSamples:I
|
|
|
|
invoke-static {p2, p3}, Lb0/i/f;->takeLast(Ljava/util/List;I)Ljava/util/List;
|
|
|
|
move-result-object p2
|
|
|
|
iget-object p3, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->history:Ljava/util/HashMap;
|
|
|
|
invoke-interface {p3, p1, p2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
const/4 p1, 0x1
|
|
|
|
iput-boolean p1, p0, Lcom/discord/utilities/frecency/FrecencyTracker;->dirty:Z
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
monitor-exit p0
|
|
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
monitor-exit p0
|
|
|
|
throw p1
|
|
.end method
|