vapor-community / bits Goto Github PK
View Code? Open in Web Editor NEWA bite sized library for dealing with bytes.
License: MIT License
A bite sized library for dealing with bytes.
License: MIT License
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.