Remove array alloc, not a good idea
This commit is contained in:
@@ -471,29 +471,6 @@ void BoundedAddError(Array<T> *arr, T item) {
|
||||
if (arr->len + 1 <= arr->cap) arr->data[arr->len++] = item;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T *Alloc(Array<T> *arr, T item) {
|
||||
TryGrowing(arr);
|
||||
T *ref = arr->data + arr->len++;
|
||||
ref[0] = item;
|
||||
return ref;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T *Alloc(Array<T> *arr) {
|
||||
return Alloc(arr, {});
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T *AllocMultiple(Array<T> *arr, int64_t count, bool zero_memory = true) {
|
||||
TryGrowing(arr, count);
|
||||
T *result = arr->data + arr->len;
|
||||
arr->len += count;
|
||||
if (zero_memory)
|
||||
for (int64_t i = 0; i < count; i += 1) result[i] = {};
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Insert(Array<T> *arr, T item, int64_t index) {
|
||||
if (index == arr->len) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
void SaveHistoryBeforeMergeCursor(Buffer *buffer, Array<HistoryEntry> *stack, Array<Caret> &carets) {
|
||||
if (buffer->no_history) return;
|
||||
HistoryEntry *entry = Alloc(stack);
|
||||
entry->carets = TightCopy(GetSystemAllocator(), carets);
|
||||
HistoryEntry entry = {};
|
||||
entry.carets = TightCopy(GetSystemAllocator(), carets);
|
||||
Add(stack, entry);
|
||||
}
|
||||
|
||||
void SaveHistoryBeforeApplyEdits(Buffer *buffer, Array<HistoryEntry> *stack, Array<Edit> &edits) {
|
||||
|
||||
Reference in New Issue
Block a user