Skip to content

Exposing JsValue::ZERO and ONE constants #3788

Closed
@Ekleog

Description

@Ekleog

Hey!

I'm writing bindings for IndexedDB, and it turns out IndexedDB does not support indexing a boolean column. The recommended way to do it is to basically index a 0/1 column, or even a column where absence of the key indicates false.

As a consequence, using these bindings means people have to use JsValue::from(1) and JsValue::from(0) quite a lot. IIUC, it means one heap allocation over FFI each time. One alternative way to do it would be to use a lazy-static, but it also feels like quite a lot of effort for things that should be reasonably simple — zero and one are pretty often-used constants.

WDYT about adding JsValue::ZERO and JsValue::ONE constants? I tried looking into making a PR for it right away, but then noticed there's some RESERVED index that seems to have some significant, so I thought I'd ask about your thoughts here first :)

(And yes this is most certainly premature optimization considering there's a disk access going on anyway, and I'll live without any issue if this feature does not land, it's just that making heap allocations like this make me sad inside)

Anyway, as usual, thank you for all you do, it's a pleasure using the rust wasm ecosystem ❤️

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions