summaryrefslogtreecommitdiff
path: root/src/noise.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2017-07-27 00:24:14 +0200
committerLoic Blot <loic.blot@unix-experience.fr>2017-07-27 00:24:14 +0200
commitbc1654feedc90caa8c26328ca6f0fc59fbe5b76c (patch)
tree925ea428d58a8c7b56e91218e7157366ae183c27 /src/noise.cpp
parentc8faee4eda27022319a25d5959205496ef75414e (diff)
downloadminetest-bc1654feedc90caa8c26328ca6f0fc59fbe5b76c.tar.gz
minetest-bc1654feedc90caa8c26328ca6f0fc59fbe5b76c.tar.bz2
minetest-bc1654feedc90caa8c26328ca6f0fc59fbe5b76c.zip
Noise::perlinMap2D,3D: replace a loop init with a single memset call
Diffstat (limited to 'src/noise.cpp')
-rw-r--r--src/noise.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/noise.cpp b/src/noise.cpp
index f67771b88..e68c5ce16 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -713,8 +713,7 @@ float *Noise::perlinMap2D(float x, float y, float *persistence_map)
if (persistence_map) {
if (!persist_buf)
persist_buf = new float[bufsize];
- for (size_t i = 0; i != bufsize; i++)
- persist_buf[i] = 1.0;
+ memset(persist_buf, 1.0f, sizeof(float) * bufsize);
}
for (size_t oct = 0; oct < np.octaves; oct++) {
@@ -751,8 +750,8 @@ float *Noise::perlinMap3D(float x, float y, float z, float *persistence_map)
if (persistence_map) {
if (!persist_buf)
persist_buf = new float[bufsize];
- for (size_t i = 0; i != bufsize; i++)
- persist_buf[i] = 1.0;
+
+ memset(persist_buf, 1.0f, sizeof(float) * bufsize);
}
for (size_t oct = 0; oct < np.octaves; oct++) {