-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't store collection reference in DeckTreeNode
Pass it in to processChildren() instead, which is cleaner, and will work better with the move to a backend method. Speed up deck list by rendering it with the backend This delegates to the backend to render the deck tree, instead of calculating it in Java. On @Arthur-Milchior's large collection with the daily limits turned up, the speed difference in an x86_64 sim is dramatic: 2.4s with the old Java code, and 70ms with the new Rust code. - Make deckDueList() private; switch callers to use deckDueTree() The backend only provides a deckDueTree(), and switching the calls to deckDueList() now will make migration easier in the future. Squashed from #11599
- Loading branch information
Showing
11 changed files
with
149 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
AnkiDroid/src/main/java/com/ichi2/libanki/sched/BackendSched.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*************************************************************************************** | ||
* Copyright (c) 2012 Ankitects Pty Ltd <http://apps.ankiweb.net> * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify it under * | ||
* the terms of the GNU General Public License as published by the Free Software * | ||
* Foundation; either version 3 of the License, or (at your option) any later * | ||
* version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License along with * | ||
* this program. If not, see <http://www.gnu.org/licenses/>. * | ||
****************************************************************************************/ | ||
|
||
package com.ichi2.libanki.sched | ||
|
||
import anki.decks.DeckTreeNode | ||
import com.ichi2.libanki.CollectionV16 | ||
import com.ichi2.libanki.utils.TimeManager | ||
|
||
// The desktop code stores these routines in sched/base.py, and all schedulers inherit them. | ||
// The presence of AbstractSched is going to complicate the introduction of the v3 scheduler, | ||
// so for now these are stored in a separate file. | ||
|
||
fun CollectionV16.deckTree(includeCounts: Boolean): DeckTreeNode { | ||
return backend.deckTree(if (includeCounts) TimeManager.time.intTime() else 0) | ||
} | ||
|
||
/** | ||
* Mutate the backend reply into a format expected by legacy code. This is less efficient, | ||
* and AnkiDroid may wish to use .deckTree() in the future instead. | ||
*/ | ||
fun CollectionV16.deckTreeLegacy(includeCounts: Boolean): List<TreeNode<DeckDueTreeNode>> { | ||
fun toLegacyNode(node: anki.decks.DeckTreeNode, parentName: String): TreeNode<DeckDueTreeNode> { | ||
val thisName = if (parentName.isEmpty()) { | ||
node.name | ||
} else { | ||
"$parentName::${node.name}" | ||
} | ||
val treeNode = TreeNode( | ||
DeckDueTreeNode( | ||
thisName, | ||
node.deckId, | ||
node.reviewCount, | ||
node.learnCount, | ||
node.newCount, | ||
) | ||
) | ||
treeNode.children.addAll(node.childrenList.asSequence().map { toLegacyNode(it, thisName) }) | ||
return treeNode | ||
} | ||
return toLegacyNode(deckTree(includeCounts), "").children | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.