perf: convert 194 interpolated Log.d() calls to lambda overloads
Defers string construction until after the level check, avoiding allocation when debug logging is filtered in release/benchmark builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -124,7 +124,7 @@ class EphemeralChatListState(
|
||||
scope.launch(Dispatchers.IO) {
|
||||
Log.d("AccountRegisterObservers", "EphemeralChatList Collector Start")
|
||||
getEphemeralChatListFlow().collect { noteState ->
|
||||
Log.d("AccountRegisterObservers", "EphemeralChatList List for ${signer.pubKey}")
|
||||
Log.d("AccountRegisterObservers") { "EphemeralChatList List for ${signer.pubKey}" }
|
||||
(noteState.note.event as? EphemeralChatListEvent)?.let {
|
||||
settings.updateEphemeralChatListTo(it)
|
||||
}
|
||||
|
||||
+2
-2
@@ -161,7 +161,7 @@ class Kind3FollowListState(
|
||||
|
||||
init {
|
||||
settings.backupContactList?.let {
|
||||
Log.d("AccountRegisterObservers", "Loading saved ${it.tags.size} contacts")
|
||||
Log.d("AccountRegisterObservers") { "Loading saved ${it.tags.size} contacts" }
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
|
||||
@@ -171,7 +171,7 @@ class Kind3FollowListState(
|
||||
scope.launch(Dispatchers.IO) {
|
||||
Log.d("AccountRegisterObservers", "Kind 3 Collector Start")
|
||||
getFollowListFlow().collect {
|
||||
Log.d("AccountRegisterObservers", "Updating Kind 3 ${signer.pubKey}")
|
||||
Log.d("AccountRegisterObservers") { "Updating Kind 3 ${signer.pubKey}" }
|
||||
(it.note.event as? ContactListEvent)?.let {
|
||||
settings.updateContactListTo(it)
|
||||
}
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ class PublicChatListState(
|
||||
|
||||
init {
|
||||
settings.channelList()?.let { event ->
|
||||
Log.d("AccountRegisterObservers", "Loading saved channel list ${event.toJson()}")
|
||||
Log.d("AccountRegisterObservers") { "Loading saved channel list ${event.toJson()}" }
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
scope.launch(Dispatchers.IO) {
|
||||
cache.justConsumeMyOwnEvent(event)
|
||||
@@ -139,7 +139,7 @@ class PublicChatListState(
|
||||
scope.launch(Dispatchers.IO) {
|
||||
Log.d("AccountRegisterObservers", "Channel List Collector Start")
|
||||
getChannelListFlow().collect {
|
||||
Log.d("AccountRegisterObservers", "Channel List for ${signer.pubKey}")
|
||||
Log.d("AccountRegisterObservers") { "Channel List for ${signer.pubKey}" }
|
||||
(it.note.event as? ChannelListEvent)?.let {
|
||||
settings.updateChannelListTo(it)
|
||||
}
|
||||
|
||||
+2
-2
@@ -142,7 +142,7 @@ class Nip65RelayListState(
|
||||
|
||||
init {
|
||||
settings.backupNIP65RelayList?.let {
|
||||
Log.d("AccountRegisterObservers", "Loading saved nip65 relay list ${it.toJson()}")
|
||||
Log.d("AccountRegisterObservers") { "Loading saved nip65 relay list ${it.toJson()}" }
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class Nip65RelayListState(
|
||||
scope.launch(Dispatchers.IO) {
|
||||
Log.d("AccountRegisterObservers", "NIP-65 Relay List Collector Start")
|
||||
getNIP65RelayListFlow().collect {
|
||||
Log.d("AccountRegisterObservers", "Updating NIP-65 List for ${signer.pubKey}")
|
||||
Log.d("AccountRegisterObservers") { "Updating NIP-65 List for ${signer.pubKey}" }
|
||||
(it.note.event as? AdvertisedRelayListEvent)?.let {
|
||||
settings.updateNIP65RelayList(it)
|
||||
}
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ inline fun <T> logTime(
|
||||
if (isDebug) {
|
||||
val (result, elapsed) = measureTimedValue(block)
|
||||
if (elapsed.inWholeMilliseconds > minToReportMs) {
|
||||
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage")
|
||||
Log.d("DEBUG-TIME") { "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage" }
|
||||
}
|
||||
result
|
||||
} else {
|
||||
@@ -54,7 +54,7 @@ inline fun <T> logTime(
|
||||
if (isDebug) {
|
||||
val (result, elapsed) = measureTimedValue(block)
|
||||
if (elapsed.inWholeMilliseconds > minToReportMs) {
|
||||
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}")
|
||||
Log.d("DEBUG-TIME") { "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}" }
|
||||
}
|
||||
result
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -49,24 +49,24 @@ abstract class FeedViewModel(
|
||||
override fun invalidateData(ignoreIfDoing: Boolean) = feedState.invalidateData(ignoreIfDoing)
|
||||
|
||||
init {
|
||||
Log.d("Init", "Starting new Model: ${this::class.simpleName}")
|
||||
Log.d("Init") { "Starting new Model: ${this::class.simpleName}" }
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
cacheProvider.getEventStream().newEventBundles.collect { newNotes ->
|
||||
Log.d("Rendering Metrics", "Update feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}")
|
||||
Log.d("Rendering Metrics") { "Update feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}" }
|
||||
feedState.updateFeedWith(newNotes)
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
cacheProvider.getEventStream().deletedEventBundles.collect { newNotes ->
|
||||
Log.d("Rendering Metrics", "Delete from feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}")
|
||||
Log.d("Rendering Metrics") { "Delete from feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}" }
|
||||
feedState.deleteFromFeed(newNotes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
Log.d("Init", "OnCleared: ${this::class.simpleName}")
|
||||
Log.d("Init") { "OnCleared: ${this::class.simpleName}" }
|
||||
super.onCleared()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,14 +46,14 @@ abstract class ListChangeFeedViewModel(
|
||||
override fun invalidateData(ignoreIfDoing: Boolean) = feedState.invalidateData(ignoreIfDoing)
|
||||
|
||||
init {
|
||||
Log.d("Init", "Starting new Model: ${this::class.simpleName}")
|
||||
Log.d("Init") { "Starting new Model: ${this::class.simpleName}" }
|
||||
// Trigger initial load so empty rooms show Empty instead of Loading
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
feedState.invalidateData(ignoreIfDoing = false)
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
localFilter.changesFlow().collect {
|
||||
Log.d("Init", "Collecting changes to: ${this@ListChangeFeedViewModel::class.simpleName}")
|
||||
Log.d("Init") { "Collecting changes to: ${this@ListChangeFeedViewModel::class.simpleName}" }
|
||||
when (it) {
|
||||
is ListChange.Addition -> feedState.updateFeedWith(setOf(it.item))
|
||||
is ListChange.Deletion -> feedState.deleteFromFeed(setOf(it.item))
|
||||
|
||||
Reference in New Issue
Block a user