UNSAFECSHARP Telegram 117
Пишите non-alloc методы.

Мы часто пишем подобные методы:

List<int> GetItems() {
var items = new List<int>();
...
return items;
}


В этом методе мы просто собираем элементы и возвращаем.
При этом создаем список, создание которого мы не можем запретить извне. Для этого лучше писать таким образом:

void GetItems(List<int> items) {
...
}


Таким образом контроль над списком может быть таким:

var list = GetFromPool();
GetItems(list);
...
ReturnToPool(list);


#gc #code #allocations
👍27🔥6🗿3👎2



tgoop.com/unsafecsharp/117
Create:
Last Update:

Пишите non-alloc методы.

Мы часто пишем подобные методы:


List<int> GetItems() {
var items = new List<int>();
...
return items;
}


В этом методе мы просто собираем элементы и возвращаем.
При этом создаем список, создание которого мы не можем запретить извне. Для этого лучше писать таким образом:

void GetItems(List<int> items) {
...
}


Таким образом контроль над списком может быть таким:

var list = GetFromPool();
GetItems(list);
...
ReturnToPool(list);


#gc #code #allocations

BY Unity: Всё, что вы не знали о разработке


Share with your friend now:
tgoop.com/unsafecsharp/117

View MORE
Open in Telegram


Telegram News

Date: |

Ng Man-ho, a 27-year-old computer technician, was convicted last month of seven counts of incitement charges after he made use of the 100,000-member Chinese-language channel that he runs and manages to post "seditious messages," which had been shut down since August 2020. Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them. End-to-end encryption is an important feature in messaging, as it's the first step in protecting users from surveillance. With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. Image: Telegram.
from us


Telegram Unity: Всё, что вы не знали о разработке
FROM American