You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first interest of this change is that we are not deep cloning all
decks when creating a Deck object which should save a little bit of
time, especially loading time on collection with a lot of decks.
Instead, we have a better typing at zero runtime cost.
The second interest is that we are certain that the fact that the Deck
is implemented as a JSONObject is hidden from the developer using this
class. Instead, they can only use the provided extension, or add the
one they needs.
While most changes are relatively trivial, moving the implementation
from everywhere in the code to Deck.kt, there are some extra changes
that were needed.
I moved `getLongOrNull` to PythonExtension given that it implements
the behavior of a Python function we want to reuse, this seems more
consistent.
As value class can't be lateinit, I hardcoded
AppCompatPreferenceActivity as being a getter for the backing field
`_deck: Deck?`.
I added in testutils/JsonUtils helper method that accepts a json
holder, and a string representing the expected json, to simplify the
use of those methods.
The code used sometime `optLong("id")` and sometime
`getLong("id")`. There seems to be no reason for the difference
between both use case, and just be random choice from the
developer. Anyway, if a deck lacks an id, any place using
`getLong("id")` would have caused the code to crash, so replacing the
`optLong` by `getLong` would, in the worst case, move the time at
which the user is asked to clean their database.
There seems to be a single key we sometime set to JSONObject.NULL, it
was `delays`. For the sake of typing, the property `delays` in `deck`
is thus of type `JSONArray?`. When the value `null` is assigned to
this property, `NULL` is saved in the object, and reciprocally.
There is no need to check whether `deck` has "empty" key before
removing it. It's not even more efficient.
0 commit comments