Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 954d4c8

Browse files
committed
Fix NoAllocHelpers.
1 parent c2e54c7 commit 954d4c8

File tree

9 files changed

+73
-76
lines changed

9 files changed

+73
-76
lines changed

Runtime/InternalBridge.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Unity.InternalAPIEngineBridge.024",
3+
"references": [],
4+
"optionalUnityReferences": [],
5+
"includePlatforms": [],
6+
"excludePlatforms": [],
7+
"allowUnsafeCode": false,
8+
"overrideReferences": false,
9+
"precompiledReferences": [],
10+
"autoReferenced": true,
11+
"defineConstraints": []
12+
}

Runtime/InternalBridge/InternalBridge.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections.Generic;
2+
3+
namespace Unity.UIWidgets.InternalBridge {
4+
public static class NoAllocHelpersBridge<T> {
5+
public static T[] ExtractArrayFromListT(List<T> list) {
6+
return UnityEngine.NoAllocHelpers.ExtractArrayFromListT(list);
7+
}
8+
9+
public static void ResizeList(List<T> list, int size) {
10+
if (size < list.Count) {
11+
list.RemoveRange(size, list.Count - size);
12+
return;
13+
}
14+
15+
if (size == list.Count) {
16+
return;
17+
}
18+
19+
if (list.Capacity < size) {
20+
list.Capacity = size;
21+
}
22+
23+
UnityEngine.NoAllocHelpers.ResizeList(list, size);
24+
}
25+
26+
public static void EnsureListElemCount(List<T> list, int size) {
27+
list.Clear();
28+
if (list.Capacity < size) {
29+
list.Capacity = size;
30+
}
31+
32+
ResizeList(list, size);
33+
}
34+
}
35+
}

Runtime/ui/painting/NoAllocHelpers.cs.meta renamed to Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Unity.UIWidgets.asmdef

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "Unity.UIWidgets",
3-
"references": [],
3+
"references": [
4+
"Unity.InternalAPIEngineBridge.024"
5+
],
46
"optionalUnityReferences": [],
57
"includePlatforms": [],
68
"excludePlatforms": [],

Runtime/foundation/basic_types.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using Unity.UIWidgets.ui;
4+
using Unity.UIWidgets.InternalBridge;
55
using UnityEngine;
66
using Object = UnityEngine.Object;
77

@@ -135,16 +135,16 @@ public static string toStringList<T>(this IList<T> it) {
135135
}
136136

137137
public static void reset<T>(this List<T> list, int size) {
138-
NoAllocHelpers<T>.EnsureListElemCount(list, size);
138+
NoAllocHelpersBridge<T>.EnsureListElemCount(list, size);
139139
}
140140

141141
public static ref T refAt<T>(this List<T> list, int index) {
142-
var array = NoAllocHelpers<T>.ExtractArrayFromListT(list);
142+
var array = NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
143143
return ref array[index];
144144
}
145145

146146
public static T[] array<T>(this List<T> list) {
147-
return NoAllocHelpers<T>.ExtractArrayFromListT(list);
147+
return NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
148148
}
149149
}
150150
}

Runtime/ui/painting/NoAllocHelpers.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

Runtime/ui/txt/linebreaker.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
1+
using System.Collections.Generic;
2+
using Unity.UIWidgets.InternalBridge;
43
using UnityEngine;
54

65
namespace Unity.UIWidgets.ui {
@@ -103,7 +102,7 @@ public List<int> getBreaks() {
103102

104103
public void resize(int size) {
105104
if (this._charWidths.Count < size) {
106-
NoAllocHelpers<float>.ResizeList(this._charWidths, size);
105+
NoAllocHelpersBridge<float>.ResizeList(this._charWidths, size);
107106
}
108107
}
109108

0 commit comments

Comments
 (0)