One more speed optimization in STL.pm
This commit is contained in:
parent
745cea8e6c
commit
e51dbb994d
1 changed files with 3 additions and 3 deletions
|
@ -48,7 +48,7 @@ sub read_file {
|
||||||
sub _read_ascii {
|
sub _read_ascii {
|
||||||
my ($fh, $facets, $vertices) = @_;
|
my ($fh, $facets, $vertices) = @_;
|
||||||
|
|
||||||
my $point_re = qr/([^ ]+)\s+([^ ]+)\s+([^ ]+)/;
|
my $point_re = qr/(([^ ]+)\s+([^ ]+)\s+([^ ]+))/;
|
||||||
|
|
||||||
my $facet;
|
my $facet;
|
||||||
my %vertices_map = ();
|
my %vertices_map = ();
|
||||||
|
@ -63,12 +63,12 @@ sub _read_ascii {
|
||||||
undef $facet;
|
undef $facet;
|
||||||
} else {
|
} else {
|
||||||
/^\s*vertex\s+$point_re/o or next;
|
/^\s*vertex\s+$point_re/o or next;
|
||||||
my $vertex_id = join ',', $1, $2, $3;
|
my $vertex_id = $1;
|
||||||
my $vertex_idx;
|
my $vertex_idx;
|
||||||
if (exists $vertices_map{$vertex_id}) {
|
if (exists $vertices_map{$vertex_id}) {
|
||||||
$vertex_idx = $vertices_map{$vertex_id};
|
$vertex_idx = $vertices_map{$vertex_id};
|
||||||
} else {
|
} else {
|
||||||
push @$vertices, [map $_ * 1, $1, $2, $3];
|
push @$vertices, [map $_ * 1, $2, $3, $4];
|
||||||
$vertex_idx = $vertices_map{$vertex_id} = $#$vertices;
|
$vertex_idx = $vertices_map{$vertex_id} = $#$vertices;
|
||||||
}
|
}
|
||||||
push @$facet, $vertex_idx;
|
push @$facet, $vertex_idx;
|
||||||
|
|
Loading…
Reference in a new issue