Skip to content

Commit 415538f

Browse files
committed
Removed resizing from HeapArray and fixed windows packaging
1 parent 2d06120 commit 415538f

File tree

3 files changed

+1
-116
lines changed

3 files changed

+1
-116
lines changed

engine/utils/collections/HeapArray.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -265,39 +265,6 @@ class MHArray
265265
count--;
266266
}
267267

268-
/**
269-
* @brief Resizes the array. Re-allocates the memory to a new size and adjusts the stateMask
270-
* accordingly
271-
* @param newSize the new size of the array
272-
*/
273-
void Resize(size_t newSize)
274-
{
275-
// Setting the array to 0 is the equivalent of destroying the array.
276-
if (newSize == 0)
277-
{
278-
Destroy();
279-
return;
280-
}
281-
282-
// Every 8 positions are represented with one 8-bit unsigned integer. As such, every 8
283-
// elements in the array represents one to the size of our collection of byte masks.
284-
size_t newByteCount = ((newSize / BitUtils::BYTE_SIZE_IN_BITS) + 1);
285-
286-
// Reallocate the two pointers
287-
ReallocateMemory(newSize);
288-
289-
// Resize our state mask. Reallocating the states simply changes the number of bytes.
290-
// We need to change the last byte available to us to represent the new number of possible
291-
// states.
292-
bitField.Resize(newByteCount);
293-
bitField.UnsetPostBits(newSize);
294-
295-
size = newSize;
296-
297-
// Adjust the count to be within the range of our new size.
298-
count = ArrayUtils::SetCount(count, 0, newSize);
299-
}
300-
301268
/**
302269
* @brief Checks if an array element has been filled
303270
* @param index the index of the element we want to check
@@ -551,7 +518,6 @@ class MHArray
551518
void DeallocateMemory()
552519
{
553520
free(data);
554-
bitField.Clear();
555521
}
556522

557523
/**

examples/game/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ render-assets:
7272

7373
# Package the built application and all its assets to the output directory
7474
package: all
75-
$(RM) $(call platformpth,$(outputDir)/$(exampleGameOutputName))
75+
$(RM) "$(outputDir)/$(exampleGameOutputName)"
7676
$(call PACKAGE_SCRIPT, $(exampleGameOutputName), $(shell basename $(exampleGameApp)), $(outputDir), $(exampleGameBuildDir))

tests/utils/test_MHArray.cpp

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -509,87 +509,6 @@ UTEST(test_MHArray, IterateWithFastIteratorWithGaps)
509509
}
510510
}
511511

512-
UTEST(test_MHArray, ResizeArray)
513-
{
514-
MHArray<uint32_t> array({1, 2, 3, 4});
515-
516-
ASSERT_EQ(array.Size(), 4);
517-
ASSERT_EQ(array.Count(), 4);
518-
519-
ASSERT_EQ(array[0], 1);
520-
ASSERT_EQ(array[1], 2);
521-
ASSERT_EQ(array[2], 3);
522-
ASSERT_EQ(array[3], 4);
523-
524-
array.Resize(6);
525-
526-
ASSERT_EQ(array.Size(), 6);
527-
ASSERT_EQ(array.Count(), 4);
528-
529-
ASSERT_EQ(array[0], 1);
530-
ASSERT_EQ(array[1], 2);
531-
ASSERT_EQ(array[2], 3);
532-
ASSERT_EQ(array[3], 4);
533-
534-
ASSERT_FALSE(array.IsActive(4));
535-
ASSERT_FALSE(array.IsActive(5));
536-
537-
array[4] = 5;
538-
array[5] = 6;
539-
540-
ASSERT_TRUE(array.IsActive(4));
541-
ASSERT_TRUE(array.IsActive(5));
542-
543-
ASSERT_EQ(array[4], 5);
544-
ASSERT_EQ(array[5], 6);
545-
ASSERT_EQ(array.Count(), 6);
546-
}
547-
548-
UTEST(test_MHArray, ResizeArrayToSmallerSize)
549-
{
550-
MHArray<uint32_t> array({1, 2, 3, 4});
551-
552-
ASSERT_EQ(array.Size(), 4);
553-
ASSERT_EQ(array.Count(), 4);
554-
555-
ASSERT_EQ(array[0], 1);
556-
ASSERT_EQ(array[1], 2);
557-
ASSERT_EQ(array[2], 3);
558-
ASSERT_EQ(array[3], 4);
559-
560-
array.Resize(2);
561-
562-
ASSERT_EQ(array.Size(), 2);
563-
ASSERT_EQ(array.Count(), 2);
564-
565-
ASSERT_EQ(array[0], 1);
566-
ASSERT_EQ(array[1], 2);
567-
568-
ASSERT_TRUE(array.IsActive(0));
569-
ASSERT_TRUE(array.IsActive(1));
570-
ASSERT_FALSE(array.IsActive(2));
571-
ASSERT_FALSE(array.IsActive(3));
572-
}
573-
574-
UTEST(test_MHArray, ResizeLargeArray)
575-
{
576-
MHArray<uint32_t> array({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
577-
578-
ASSERT_EQ(array.Size(), 10);
579-
ASSERT_EQ(array.Count(), 10);
580-
581-
uint32_t number = 1;
582-
583-
for (auto it = array.CreateIterator(); it; ++it) ASSERT_EQ(number++, *it);
584-
585-
array.Resize(9);
586-
587-
ASSERT_EQ(array.Size(), 9);
588-
ASSERT_EQ(array.Count(), 9);
589-
590-
ASSERT_FALSE(array.IsActive(9));
591-
}
592-
593512
UTEST(test_MHArray, ClearArray)
594513
{
595514
MHArray<uint32_t> array({1, 2});

0 commit comments

Comments
 (0)