Optimize GC for PropSrc.

This commit is contained in:
2022-12-25 22:20:46 +08:00
parent e589e37640
commit 44180c7e0f
3 changed files with 49 additions and 38 deletions

View File

@@ -244,17 +244,17 @@ namespace Cryville.Crtr {
_buf = null;
}
}
protected override unsafe void InternalGet(out int type, out byte[] value) {
protected override unsafe int InternalGet() {
var src = _cb();
int strlen = src.Length;
type = PdtInternalType.String;
value = _pool.Rent(sizeof(int) + strlen * sizeof(char));
fixed (byte* _ptr = value) {
buf = _pool.Rent(sizeof(int) + strlen * sizeof(char));
fixed (byte* _ptr = buf) {
char* ptr = (char*)(_ptr + sizeof(int));
*(int*)_ptr = strlen;
int i = 0;
foreach (var c in src) ptr[i++] = c;
}
return PdtInternalType.String;
}
}
#endregion