GithubHelp home page GithubHelp logo

Comments (4)

WojciechMula avatar WojciechMula commented on June 12, 2024 1

Another thing for base64 encoding - it would be practical if we allowed wrapping output, for instance:

const size_t max_line_length = 72;
const char* separator = "\n";
encode(input, output, max_line_length, separator);
```

Again, nobody would expect that this variant will be as fast as the plain encoding.

from simdutf.

lemire avatar lemire commented on June 12, 2024 1

Please see #382 where the base64 API was slightly extended (i.e., we have _safe functions).

from simdutf.

WojciechMula avatar WojciechMula commented on June 12, 2024

I was thinking a little about API. My generic proposal is providing a convenient wrapper that would work incrementally. I mean: user provides partial data (like input buffer when reading from file) and output buffer of fixed size. Using for decoding would be something like:

auto decoder = Base64Decoder::new();

std::string input;
input.resize(32 * 1024);

std::string output;
output.resize(16 * 1024);
while (/**/) {
      // read a few kilobytes data from into `input`
  
      const size_t bytes_stored = decoder.decode(input.data(), input.size(), output.data(), output.size());
      // bytes_stored will never be greater than output.size()

      write (output.data(), bytes_stored)

      if input file reached EOF {
          while (decoder.pending_output()) {
              const size_t bytes_stored = decoder.flush(output.data(), output.size());
              write (output.data(), bytes)
         }
      }
}

Of course this flexibility is at cost of performance, but my gut feeling is that if somebody want to process data in chunks, than problem is likely I/O bound.

from simdutf.

lemire avatar lemire commented on June 12, 2024

@WojciechMula I'm pinging you later today as I have a major upgrade to the base64 support, with a slightly improved API.

from simdutf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.