Skip to content

Commit f64f96e

Browse files
committed
Improved performance
1 parent a641e63 commit f64f96e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

PerlinNoise.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ PerlinNoise::PerlinNoise( unsigned seed )
1414
seed = std::mt19937::default_seed;
1515
}
1616

17-
// "permutation" contains all numbers in [0..255] in random order
18-
std::array<int,256> permutation;
19-
std::iota(permutation.begin(),permutation.end(),0);
20-
std::shuffle(permutation.begin(),permutation.end(),std::mt19937(seed));
17+
// p[0]..p[255] contains all numbers in [0..255] in random order
18+
std::iota(std::begin(p),std::begin(p)+256,0);
19+
20+
std::shuffle(std::begin(p),std::begin(p)+256,std::mt19937(seed));
2121

2222
for(int i=0; i<256; ++i)
2323
{
24-
p[256+i] = p[i] = permutation[i];
24+
p[256+i] = p[i];
2525
}
2626
}
2727

0 commit comments

Comments
 (0)