writeList vs open-coding

Issue #1 new
Paolo Giarrusso created an issue

I wondered about your results so I went to compare the two fragments. While writeObject serializes the list by hand, writeToParcel serializes it using writeList after testing if it's null.

  • Nitpick: writeList already handles null correctly.
  • More importantly: writeList uses writeValue, which uses a chain of instanceof before using writeParcelable (the documentation makes that necessary). Instead, writeObject uses writeObject directly. Given that instanceof can be quite slow, I wonder if this is an important cause of the slowdown.

Comments (3)

  1. Paolo Giarrusso reporter

    As a side note, Parcel.writeValue docs do not warn that it's so slow, and that's certainly a documentation issue.

  2. Alex Frishman repo owner

    @Blaisorblade Very interesting suggestion, thank you. Need to try to manually write instead of using the writeList

  3. Gabor Varadi

    I’m more-so surprised that for { readObject( is used, why not readTypedList / writeTypedList ?

  4. Log in to comment