Merge remote-tracking branch 'upstream/stable' into merge_stable

This commit is contained in:
Martin Nowak 2020-05-11 19:29:12 +02:00
commit a7d8def71b
4 changed files with 26 additions and 28 deletions

View file

@ -1,14 +0,0 @@
Add `Date.isoWeekYear` and `Date.fromISOWeek` in `std.datetime.date`
It is now possible to convert from the ISO 8601 week calendar into the
Gregorian calendar which is used by Date and DateTime.
Dates are constructed from the year in the ISO week calendar, the week number
and a day of week. `Date.fromISOWeek(2020, 11, DayOfWeek.mon)` will result in
`Date(2020, 3, 9)`.
As the year in the Gregorian calendar and the year in the ISO week calendar are
not always the same there is a new `.isoWeekYear` property to get the year of
the `Date` object in the ISO week calendar. If you convert between them often,
consider using `.isoWeekAndYear` to compute both week number and year in one
step.

View file

@ -1,6 +0,0 @@
Deprecated module `std.xml`
The module `std.xml` has been deprecated. Any code that still needs
it can use [UndeaD](https://github.com/dlang/undeaD) instead.
For parsing xml files, we recommend to use the dub package
[dxml](https://code.dlang.org/packages/dxml).

View file

@ -1,7 +0,0 @@
The deprecated aliases in std.digest.digest were removed
They were deprecated since 2.076.1 and have now been removed.
Import `std.digest` or its submodules instead.
Additionally the deprecation cycle for `std.digest.digest` was started
and the module will be removed in 2.101.

View file

@ -3000,7 +3000,13 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R &&
bool overflow;
const nbytes = mulu(len, T.sizeof, overflow);
if (overflow) assert(false, "multiplication overflowed");
return (cast(T*) malloc(nbytes))[0 .. len];
T[] result = (cast(T*) malloc(nbytes))[0 .. len];
static if (hasIndirections!T)
{
import core.memory : GC;
GC.addRange(result.ptr, nbytes);
}
return result;
}
auto xform1 = trustedMalloc(r.length);
@ -3014,6 +3020,11 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R &&
static void trustedFree(T[] p) @trusted
{
import core.stdc.stdlib : free;
static if (hasIndirections!T)
{
import core.memory : GC;
GC.removeRange(p.ptr);
}
free(p.ptr);
}
trustedFree(xform1);
@ -3143,6 +3154,20 @@ if (isRandomAccessRange!R && hasLength!R && hasSwappableElements!R)
assert(isSorted!("a < b")(map!(entropy)(arr)));
}
// https://issues.dlang.org/show_bug.cgi?id=20799
@safe unittest
{
import std.range : iota, retro;
import std.array : array;
auto arr = 1_000_000.iota.retro.array;
arr.schwartzSort!(
n => new int(n),
(a, b) => *a < *b
);
assert(arr.isSorted());
}
// partialSort
/**
Reorders the random-access range `r` such that the range `r[0 .. mid]`