Skip to content

drop manual StringBuf deletes, use into-string #26

Description

@hellerve

strbuf 0.3.0 is out. Since 0.2.1 the compiler deletes buffers for us (implements delete), and 0.3.0 adds into-string, which consumes a buffer and hands its allocation to the returned String without copying.

Copy-then-free sites, each of which becomes a single (StringBuf.into-string sb):

  • http-client.carp:523-524 — header accumulation in the receive loop
  • http-client.carp:807-808drain-stream
  • src/cookie-jar.carp:201-202
  • src/multipart.carp:208

Plain scope-end deletes that can just go away, since the buffer is freed at scope exit:

  • bench/string-accumulate.carp:48, 66 — worth a look rather than a blind delete: if the benchmark is meant to measure the create/append/free cycle, keeping the explicit call is defensible, but then it is measuring something the library no longer asks users to do

Pins to bump to strbuf@0.3.0: http-client.carp:4, bench/string-accumulate.carp:2.

Nothing breaks if this waits: manual delete is still an ownership transfer and does not double free.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions