<commit_before>package geom

import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
)

// MultiPoint represents a collection of points.
type MultiPoint struct {
	Points []Point
}

type geoJSONMultiPoint struct {
	Type        string      `json:"type"`
	Coordinates [][]float64 `json:"coordinates"`
}

// MarshalJSON returns the GeoJSON encoding of a MultiPoint.
func (multi *MultiPoint) MarshalJSON() ([]byte, error) {
	var buffer bytes.Buffer

	buffer.WriteString(`{"type":"MultiPoint","coordinates":[`)
	for i, point := range multi.Points {
		if i != 0 {
			buffer.WriteString(`,`)
		}
		buffer.WriteString(`[`)
		for j, value := range point.Coordinates {
			if j != 0 {
				buffer.WriteString(`,`)
			}
			buffer.WriteString(strconv.FormatFloat(value, 'g', -1, 64))
		}
		buffer.WriteString(`]`)
	}

	buffer.WriteString(`]}`)
	return buffer.Bytes(), nil
}

// UnmarshalJSON creates a MultiPoint from GeoJSON.
func (multi *MultiPoint) UnmarshalJSON(data []byte) error {
	geoJSON := &geoJSONMultiPoint{}
	if err := json.Unmarshal(data, geoJSON); err != nil {
		return err
	}
	if geoJSON.Type != "MultiPoint" {
		return fmt.Errorf(`Unexpected type: "%s"`, geoJSON.Type)
	}
	if len(geoJSON.Coordinates) < 1 {
		return errors.New("Expected a coordinates array with one or more values")
	}
	var points []Point
	for _, coord := range geoJSON.Coordinates {
		points = append(points, Point{coord})
	}
	multi.Points = points
	return nil
}<commit_msg>Single allocation<commit_after>package geom

import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
)

// MultiPoint represents a collection of points.
type MultiPoint struct {
	Points []Point
}

type geoJSONMultiPoint struct {
	Type        string      `json:"type"`
	Coordinates [][]float64 `json:"coordinates"`
}

// MarshalJSON returns the GeoJSON encoding of a MultiPoint.
func (multi *MultiPoint) MarshalJSON() ([]byte, error) {
	var buffer bytes.Buffer

	buffer.WriteString(`{"type":"MultiPoint","coordinates":[`)
	for i, point := range multi.Points {
		if i != 0 {
			buffer.WriteString(`,`)
		}
		buffer.WriteString(`[`)
		for j, value := range point.Coordinates {
			if j != 0 {
				buffer.WriteString(`,`)
			}
			buffer.WriteString(strconv.FormatFloat(value, 'g', -1, 64))
		}
		buffer.WriteString(`]`)
	}

	buffer.WriteString(`]}`)
	return buffer.Bytes(), nil
}

// UnmarshalJSON creates a MultiPoint from GeoJSON.
func (multi *MultiPoint) UnmarshalJSON(data []byte) error {
	geoJSON := &geoJSONMultiPoint{}
	if err := json.Unmarshal(data, geoJSON); err != nil {
		return err
	}
	if geoJSON.Type != "MultiPoint" {
		return fmt.Errorf(`Unexpected type: "%s"`, geoJSON.Type)
	}
	if len(geoJSON.Coordinates) < 1 {
		return errors.New("Expected a coordinates array with one or more values")
	}
	points := make([]Point, len(geoJSON.Coordinates))
	for i, coord := range geoJSON.Coordinates {
		points[i] = Point{coord}
	}
	multi.Points = points
	return nil
}
{'fraction_non_alphanumeric': 0.14681724845995894, 'fraction_numerical': 0.0054757015742642025, 'mean_word_length': 4.119089316987741, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2041020', 'n_tokens_mistral': 1042, 'n_tokens_neox': 958, 'n_words': 263}