<commit_before>package Slic3r::Polyline;
use strict;
use warnings;

use Math::Clipper qw();
use Scalar::Util qw(reftype);
use Slic3r::Geometry qw(A B polyline_remove_parallel_continuous_edges polyline_remove_acute_vertices
    move_points same_point);

# the constructor accepts an array(ref) of points
sub new {
    my $class = shift;
    my $self;
    if (@_ == 1) {
        $self = [ @{$_[0]} ];
    } else {
        $self = [ @_ ];
    }
    
    bless $self, $class;
    bless $_, 'Slic3r::Point' for @$self;
    $self;
}

sub clone {
    my $self = shift;
    return (ref $self)->new(map $_->clone, @$self);
}

sub serialize {
    my $self = shift;
    my $s = \ pack 'l*', map @$_, @$self;
    bless $s, ref $self;
    return $s;
}

sub deserialize {
    my $self = shift;
    return $self if reftype $self ne 'SCALAR';
    my @v = unpack '(l2)*', $$self;
    my $o = [ map [ $v[2*$_], $v[2*$_+1] ], 0 .. int($#v/2) ];
    bless $_, 'Slic3r::Point' for @$o;
    bless $o, ref $self;
    return $o;
}

sub id {
    my $self = shift;
    return join ' - ', sort map $_->id, @$self;
}

sub lines {
    my $self = shift;
    my @lines = ();
    my $previous_point;
    foreach my $point (@$self) {
        if ($previous_point) {
            push @lines, Slic3r::Line->new($previous_point, $point);
        }
        $previous_point = $point;
    }
    return @lines;
}

sub boost_linestring {
    my $self = shift;
    return Boost::Geometry::Utils::linestring($self);
}<commit_msg>Use Slic3r::Geometry polyline_lines rather than duplicate implementation.<commit_after>package Slic3r::Polyline;
use strict;
use warnings;

use Math::Clipper qw();
use Scalar::Util qw(reftype);
use Slic3r::Geometry qw(A B polyline_remove_parallel_continuous_edges polyline_remove_acute_vertices
    move_points same_point);

# the constructor accepts an array(ref) of points
sub new {
    my $class = shift;
    my $self;
    if (@_ == 1) {
        $self = [ @{$_[0]} ];
    } else {
        $self = [ @_ ];
    }
    
    bless $self, $class;
    bless $_, 'Slic3r::Point' for @$self;
    $self;
}

sub clone {
    my $self = shift;
    return (ref $self)->new(map $_->clone, @$self);
}

sub serialize {
    my $self = shift;
    my $s = \ pack 'l*', map @$_, @$self;
    bless $s, ref $self;
    return $s;
}

sub deserialize {
    my $self = shift;
    return $self if reftype $self ne 'SCALAR';
    my @v = unpack '(l2)*', $$self;
    my $o = [ map [ $v[2*$_], $v[2*$_+1] ], 0 .. int($#v/2) ];
    bless $_, 'Slic3r::Point' for @$o;
    bless $o, ref $self;
    return $o;
}

sub id {
    my $self = shift;
    return join ' - ', sort map $_->id, @$self;
}

sub lines {
    my $self = shift;
    return polyline_lines($self);
}

sub boost_linestring {
    my $self = shift;
    return Boost::Geometry::Utils::linestring($self);
}
{'fraction_non_alphanumeric': 0.16891412349183818, 'fraction_numerical': 0.009226401703335699, 'mean_word_length': 2.768716577540107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '5965801', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1070, 'n_words': 290}