Skip to content

Commit 1bf7f83

Browse files
committed
geojson: use nocopyRawMessage for feature collection unmarshal
no speed improvement but lots of bytes saved benchmark old bytes new bytes delta BenchmarkFeatureUnmarshalJSON-12 941182 828250 -12.00%
1 parent 74bdecd commit 1bf7f83

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

geojson/feature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (f Feature) MarshalJSON() ([]byte, error) {
5757
// Alternately one can call json.Unmarshal(f) directly for the same result.
5858
func UnmarshalFeature(data []byte) (*Feature, error) {
5959
f := &Feature{}
60-
err := json.Unmarshal(data, f)
60+
err := f.UnmarshalJSON(data)
6161
if err != nil {
6262
return nil, err
6363
}

geojson/feature_collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (fc FeatureCollection) MarshalJSON() ([]byte, error) {
6969
// UnmarshalJSON decodes the data into a GeoJSON feature collection.
7070
// Extra/foreign members will be put into the `ExtraMembers` attribute.
7171
func (fc *FeatureCollection) UnmarshalJSON(data []byte) error {
72-
tmp := make(map[string]json.RawMessage, 4)
72+
tmp := make(map[string]nocopyRawMessage, 4)
7373

7474
err := json.Unmarshal(data, &tmp)
7575
if err != nil {

0 commit comments

Comments
 (0)