Add an element count to write-array

Open Beginner friendly
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
64/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
clojure
Domain
backend

Research direction

Start from the write-array definition in the ffi namespace and the typed write functions it sits beside, since the issue points to coffi's write-doubles as the model for a count argument. Add the optional trailing n after offset so that only the first n elements are written, and check the existing write-array tests still pass with the old arity. Done when a test writes a partly filled buffer with n and the bytes beyond n are left untouched.

Written by the indexing model from the issue text.

Description

write-array writes all of arr. A staging buffer sized for the largest frame and filled part way has to be copied into a smaller array before the write, which is the allocation the staging buffer exists to avoid.

Proposed, as a trailing argument after offset:

(write-array p t arr offset n) ; writes the first n elements of arr

coffi's write-doubles and the other typed writes take a count. Raised in the jolt discussion on jolt-lang/jolt#1338, from gameth's call sites.

Dominant language
Clojure
Stars
25
Forks
3
Avg merge
1m
Merged PRs (30d)
5

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 babashka/ffi

All issues in babashka/ffi

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.