Avoid redundant shallow copy when getting read-only map fields (#741)

`_FieldSet._$getMap` unnecessarily shallow-copies the map field when the
message is read-only.

If a message is read-only then all of its fields are read-only, so the
map fields are read-only. We don't need to copy them.

Copying map fields on every access can be expensive depending on the map
size, so this will potentially be a significant performance win.

(Also, if we had to copy, we would have to deep-copy, rather than
shallow-copy, so the code would be buggy if we needed to copy the field)

Also fix `_isReadonly` field initialization in `PbMap.unmodifiable`.

We do not use `PbMap.unmodifiable` and we don't have any users of it, but I
think that method will be useful when fixing #705, so I'm not removing it for
now.
3 files changed
tree: 2e9e24f3eaeebe6b1af67e517c529094c82ebc80
  1. .github/
  2. api_benchmark/
  3. benchmarks/
  4. protobuf/
  5. protoc_plugin/
  6. tool/
  7. .gitignore
  8. AUTHORS
  9. LICENSE
  10. mono_repo.yaml
  11. README.md
README.md

CI status

Protobuf support for Dart

Protocol Buffers (protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.

This repository is home to packages related to protobuf for Dart.

PackageDescriptionPublished Version
protobufA support library for the generated codepub package
protoc_pluginA Dart back-end for the protoc compilerpub package
api_benchmarkBenchmarking for various API calls
query_benchmarkBenchmark for encoding and decoding of a “real-world” protobuf