mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 07:00:37 +03:00
Merge pull request #4635 from JackStouffer/immutable2
[trivial] Added immutable to several variables in std.numeric
This commit is contained in:
commit
13b9ab8074
1 changed files with 7 additions and 7 deletions
|
@ -403,7 +403,7 @@ public:
|
||||||
static @property size_t dig()
|
static @property size_t dig()
|
||||||
{
|
{
|
||||||
auto shiftcnt = precision - ((flags&Flags.storeNormalized) != 0);
|
auto shiftcnt = precision - ((flags&Flags.storeNormalized) != 0);
|
||||||
auto x = (shiftcnt == 64) ? 0 : 1uL << shiftcnt;
|
immutable x = (shiftcnt == 64) ? 0 : 1uL << shiftcnt;
|
||||||
return cast(size_t) log10(x);
|
return cast(size_t) log10(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1635,7 +1635,7 @@ euclideanDistance(Range1, Range2)(Range1 a, Range2 b)
|
||||||
Unqual!(typeof(return)) result = 0;
|
Unqual!(typeof(return)) result = 0;
|
||||||
for (; !a.empty; a.popFront(), b.popFront())
|
for (; !a.empty; a.popFront(), b.popFront())
|
||||||
{
|
{
|
||||||
auto t = a.front - b.front;
|
immutable t = a.front - b.front;
|
||||||
result += t * t;
|
result += t * t;
|
||||||
}
|
}
|
||||||
static if (!haveLen) enforce(b.empty);
|
static if (!haveLen) enforce(b.empty);
|
||||||
|
@ -1660,7 +1660,7 @@ euclideanDistance(Range1, Range2, F)(Range1 a, Range2 b, F limit)
|
||||||
static if (!haveLen) enforce(b.empty);
|
static if (!haveLen) enforce(b.empty);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto t = a.front - b.front;
|
immutable t = a.front - b.front;
|
||||||
result += t * t;
|
result += t * t;
|
||||||
if (result >= limit) break;
|
if (result >= limit) break;
|
||||||
}
|
}
|
||||||
|
@ -1857,14 +1857,14 @@ bool normalize(R)(R range, ElementType!(R) sum = 1)
|
||||||
{
|
{
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
auto f = sum / range.length;
|
immutable f = sum / range.length;
|
||||||
foreach (ref e; range) e = f;
|
foreach (ref e; range) e = f;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// The path most traveled
|
// The path most traveled
|
||||||
assert(s >= 0);
|
assert(s >= 0);
|
||||||
auto f = sum / s;
|
immutable f = sum / s;
|
||||||
foreach (ref e; range)
|
foreach (ref e; range)
|
||||||
e *= f;
|
e *= f;
|
||||||
return true;
|
return true;
|
||||||
|
@ -2600,7 +2600,7 @@ T gcd(T)(T a, T b)
|
||||||
}
|
}
|
||||||
while (b)
|
while (b)
|
||||||
{
|
{
|
||||||
auto t = b;
|
immutable t = b;
|
||||||
b = a % b;
|
b = a % b;
|
||||||
a = t;
|
a = t;
|
||||||
}
|
}
|
||||||
|
@ -3066,7 +3066,7 @@ public:
|
||||||
immutable lenNeg1 = 1.0 / buf.length;
|
immutable lenNeg1 = 1.0 / buf.length;
|
||||||
foreach (ref elem; buf)
|
foreach (ref elem; buf)
|
||||||
{
|
{
|
||||||
auto temp = elem.re * lenNeg1;
|
immutable temp = elem.re * lenNeg1;
|
||||||
elem.re = elem.im * lenNeg1;
|
elem.re = elem.im * lenNeg1;
|
||||||
elem.im = temp;
|
elem.im = temp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue