Return i64 and f64 instead of &i64 and &f64 in Value

Open
#2,235 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 11 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
databases

Research direction

Locate the definitions and callers of Value::as_integer and Value::as_real, then inspect nearby tests or API documentation for the current reference-returning behavior. Determine whether returning copied values is compatible with existing callers; done means the chosen return types are implemented consistently and relevant tests and callers pass.

Written by the indexing model from the issue text.

Description

While going through the codebase, I noticed that Value::as_integer and Value::as_real return Option<&i64> and Option<&f64> respectively, rather than Option and Option.

Since i64 and f64 are both Copy and only 8 bytes (the same size as a reference on a 64-bit target), returning a reference offers no performance benefit and forces every caller to dereference. Is there a specific reason for this, or would a change to return by value be welcome?

For comparison, serde_json::Value::as_i64/as_f64 returns these by value.

Dominant language
C
Stars
17.3k
Forks
562
Avg merge
10d 15h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tursodatabase/libsql

All issues in tursodatabase/libsql

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.