derivation_examples icon indicating copy to clipboard operation
derivation_examples copied to clipboard

An idea to increase the performance of the toMap funtion even more.

Open borissmidt opened this issue 3 years ago • 1 comments

I saw you using the mutable maps in the presentation and i was wondering if it was possible to make an immutable map macro that would be even faster then the mutable map building.

In the case of toMap typeclass couldn't the inline macro 'pre-hash' the already known String keys and thus push performance above the level of mutable code and 'sane handwritten code'.

Book(authoer: String, isbn: Long)
val book = Book("author", 12345L)
Mapper.toMap(book)
//inlined 'macro'
{ Map("author" -> book.author, "isbn" -> book.isbn) } // i.e. author and isbn are always the same couldn't the hashing be done at compile time.

borissmidt avatar Mar 02 '21 17:03 borissmidt