Permalink
Browse files

Stripped out fallback encoder/decoder/verifier completely (even IE8 s…

…upports codegen), significantly reduces bundle size, can use static codegen elsewhere
  • Loading branch information...
dcodeIO committed Dec 18, 2016
1 parent c234de7 commit bfac0ea9afa3dbaf5caf79ddf0600c3c7772a538
@@ -402,7 +402,7 @@ While .proto and JSON files require the full library (about 18kb gzipped), prett
Static code, on the other hand, requires just the minimal runtime (about 5.5kb gzipped), but generates additional, albeit editable, source code without any reflection features.
Where `new Function(...)` is supported (it usually is), there is no difference performance-wise as the code generated statically is pretty much the same as generated at runtime.
There is no difference performance-wise as the code generated statically is pretty much the same as generated at runtime.
Building
--------
@@ -493,8 +493,6 @@ Note that JSON is a native binding nowadays and as such is about as fast as it p
* For entirely bogus values encoders intentionally rely on runtime errors to be thrown somewhere down the road.
* Quite a bit of V8-specific profiling is accountable for everything else.
Note that code generation requires `new Function(...)` (basically `eval`) support and that an equivalent but slower fallback will be used where unsupported.
You can also run [the benchmark](https://github.com/dcodeIO/protobuf.js/blob/master/bench/index.js) ...
```
@@ -282,7 +282,7 @@ function buildType(ref, type) {
"@param {Writer} [writer] Writer to encode to",
"@returns {Writer} Writer"
]);
buildFunction(type, "encode", protobuf.encode.generate(type), {
buildFunction(type, "encode", protobuf.encoder(type), {
Writer : "$protobuf.Writer",
util : "$protobuf.util"
});
@@ -318,7 +318,7 @@ function buildType(ref, type) {
"@param {number} [length] Message length if known beforehand",
"@returns {" + fullName + "} " + type.name
]);
buildFunction(type, "decode", protobuf.decode.generate(type), {
buildFunction(type, "decode", protobuf.decoder(type), {
Reader : "$protobuf.Reader",
util : "$protobuf.util"
});
@@ -351,7 +351,7 @@ function buildType(ref, type) {
"@param {" + fullName + "|Object} message " + type.name + " or plain object to verify",
"@returns {?string} `null` if valid, otherwise the reason why it is not"
]);
buildFunction(type, "verify", protobuf.verify.generate(type), {
buildFunction(type, "verify", protobuf.verifier(type), {
util : "$protobuf.util"
});
Oops, something went wrong.

0 comments on commit bfac0ea

Please sign in to comment.