Giter VIP home page Giter VIP logo

bits's People

Contributors

brettrtoomey avatar loganwright avatar rpinz avatar tanner0101 avatar vzsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bits's Issues

Sequence.makeString() returns empty string on failure.

In ByteSequence+Conversions.swift.

This behavior seems likely to cause silent errors, as opposed to throwing or returning an optional string.

As an example, I was trying to get the string representation of a BCrypt salt back out of the digest. My first attempt (totally wrong, I should have used Serializer) was this:

try BCrypt.Parser(hashBytes).parseSalt().bytes.makeString()

It returned "" rather than indicating failure.

Array<UInt8> is significantly slower than Data

While trying to debug some performance issues I was having today, I realised the root of my problems was an insanely slow parse in Multipart. Not that the work I was doing was too slow - the parser itself was slow.

I opened up the project in Xcode and added a simple test:

measure {
    let parser = try! Parser(boundary: "MimeBoundary_8923gr836bidfb3i")
    
    var parts: [Part] = []
    parser.onPart = { part in
        parts.append(part)
    }

    parts = []
    try! parser.parse(message)
    XCTAssertEqual(parts.count, 2)
}

For a 332kB message, with two parts (some text and a JPEG image), the implementation using Bytes (i.e. [UInt8]) took 0.422s. Replacing Bytes with Data resulted in the same test executing in 0.0475s. That's nearly a 10x speedup.

Now admittedly Multipart is a small library, and it wasn't zero work to change it over to use Data. Vapor as a whole is enormous, and such a changeover would require care and attention and a lot of work. But I think Bits really can't continue defining its own type for data when that type is so much slower than the native type. IMO, Bits should be a library for operating on Data objects, and Collections/Sequences of UInt8, and should ditch the Bytes type entirely.

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.