google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
22.56k stars 3.19k forks source link

[Kotlin-kmp] Use built-in enum class #8241

Closed DadiBit closed 3 months ago

DadiBit commented 4 months ago

Using the built-in enum class kotlin's enum implementation makes the final code easier to read, cleaner, more standard.

To stay backward compatible, I had to add a "name" method and a "names" property. Same story goes for the operator invoke, which replaces the old class constructor.

Notes:

google-cla[bot] commented 4 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

paulovap commented 3 months ago

Hi @DadiBit, the main reason for not using native enum is the performance penalty of using it as compared to primitives (or inline classes). The library focus on performance over ergonomics, so we are in favor of improving the ease of use only if the performance trade of is worth it.