Optimize GC for PropSrc.
This commit is contained in:
@@ -928,25 +928,25 @@ namespace Cryville.Crtr {
|
||||
public class VectorSrc : PropSrc {
|
||||
readonly Func<Vector> _cb;
|
||||
public VectorSrc(Func<Vector> cb) { _cb = cb; }
|
||||
protected override unsafe void InternalGet(out int type, out byte[] value) {
|
||||
protected override unsafe int InternalGet() {
|
||||
var arr = _cb().ToArray();
|
||||
if (arr.Length == 1) {
|
||||
type = PdtInternalType.Number;
|
||||
value = new byte[sizeof(float)];
|
||||
fixed (byte* ptr = value) {
|
||||
buf = new byte[sizeof(float)];
|
||||
fixed (byte* ptr = buf) {
|
||||
*(float*)ptr = arr[0];
|
||||
}
|
||||
return PdtInternalType.Number;
|
||||
}
|
||||
else {
|
||||
type = PdtInternalType.Vector;
|
||||
value = new byte[sizeof(float) * arr.Length + sizeof(int)];
|
||||
fixed (byte* rptr = value) {
|
||||
buf = new byte[sizeof(float) * arr.Length + sizeof(int)];
|
||||
fixed (byte* rptr = buf) {
|
||||
var ptr = (float*)rptr;
|
||||
for (int i = 0; i < arr.Length; i++, ptr++) {
|
||||
*ptr = arr[i];
|
||||
}
|
||||
*(int*)ptr = PdtInternalType.Number;
|
||||
}
|
||||
return PdtInternalType.Vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user