Skip to content

Commit 780379a

Browse files
committed
fix Small Array/String opAssign
1 parent 3410399 commit 780379a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

source/mir/small_array.d

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,20 @@ struct SmallArray(T, uint maxLength)
5252
this.opAssign(array);
5353
}
5454

55+
/// ditto
56+
this(SmallArray array) nothrow
57+
{
58+
this.opAssign(array);
59+
}
60+
5561
/// ditto
5662
this(uint n)(SmallArray!(T, n) array)
5763
{
5864
this.opAssign(array);
5965
}
6066

6167
/// ditto
62-
this(uint n)(ref SmallArray!(T, n) array)
68+
this(uint n)(ref const SmallArray!(T, n) array)
6369
{
6470
this.opAssign(array);
6571
}
@@ -102,21 +108,23 @@ struct SmallArray(T, uint maxLength)
102108
}
103109

104110
/// ditto
105-
ref typeof(this) opAssign(ref SmallArray rhs) return nothrow
111+
ref typeof(this) opAssign(ref const SmallArray rhs) return nothrow
106112
{
113+
_length = rhs._length;
107114
_data = rhs._data;
108115
return this;
109116
}
110117

111118
/// ditto
112119
ref typeof(this) opAssign(SmallArray rhs) return nothrow
113120
{
121+
_length = rhs._length;
114122
_data = rhs._data;
115123
return this;
116124
}
117125

118126
/// ditto
119-
ref typeof(this) opAssign(uint n)(ref SmallArray!(T, n) rhs) return
127+
ref typeof(this) opAssign(uint n)(ref const SmallArray!(T, n) rhs) return
120128
if (n != maxLength)
121129
{
122130
static if (n < maxLength)
@@ -150,7 +158,7 @@ struct SmallArray(T, uint maxLength)
150158
}
151159
else
152160
{
153-
if (rhs._data[maxLength])
161+
if (rhs._length > maxLength)
154162
{
155163
version(D_Exceptions) throw exception;
156164
else assert(0, errorMsg);

source/mir/small_string.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ extern(D):
6060
this.opAssign(str);
6161
}
6262

63+
/// ditto
64+
this(SmallString str) nothrow
65+
{
66+
this.opAssign(str);
67+
}
68+
6369
/// ditto
6470
this(uint n)(SmallString!n str)
6571
{

0 commit comments

Comments
 (0)