From 0af0cfc8ea31c8e93537bca41fd765793a53d763 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 5 Jul 2022 18:28:55 +0100 Subject: [PATCH] Change `_aaNew` to return `Impl*`, not `AA` _aaNew was added recently in #3863. This is consistent with `_d_assocarrayliteralTX` returning `Impl*`. Also flesh out docs for _d_assocarrayliteralTX. --- src/rt/aaA.d | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/rt/aaA.d b/src/rt/aaA.d index 307c1765b8..c345f9e6dd 100644 --- a/src/rt/aaA.d +++ b/src/rt/aaA.d @@ -492,11 +492,9 @@ pure nothrow @nogc unittest * Returns: * A new associative array. */ -extern (C) AA _aaNew(const TypeInfo_AssociativeArray ti) +extern (C) Impl* _aaNew(const TypeInfo_AssociativeArray ti) { - AA aa; - aa.impl = new Impl(ti); - return aa; + return new Impl(ti); } /// Determine number of entries in associative array. @@ -750,7 +748,15 @@ extern (C) int _aaApply2(AA aa, const size_t keysz, dg2_t dg) return 0; } -/// Construct an associative array of type ti from keys and value +/** Construct an associative array of type ti from corresponding keys and values. + * Called for an AA literal `[k1:v1, k2:v2]`. + * Params: + * ti = TypeInfo for the associative array + * keys = array of keys + * vals = array of values + * Returns: + * A new associative array opaque pointer, or null if `keys` is empty. + */ extern (C) Impl* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void[] keys, void[] vals) {