Tweaks.
This commit is contained in:
@@ -116,7 +116,6 @@ class ArenaContainer : public Container {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Allocation function.
|
||||
void* Place(int size) {
|
||||
ArenaContainerHeader* header = reinterpret_cast<ArenaContainerHeader*>(header_);
|
||||
@@ -132,7 +131,8 @@ class ArenaContainer : public Container {
|
||||
ObjHeader* PlaceObject(const TypeInfo* type_info);
|
||||
|
||||
// Places an array of certain type in this container. Note that array_type_info
|
||||
// is type infor for an array, not for an individual element.
|
||||
// is type info for an array, not for an individual element. Also note that exactly
|
||||
// same operation could be used to place strings.
|
||||
ArrayHeader* PlaceArray(const TypeInfo* array_type_info, int count);
|
||||
|
||||
// Dispose whole container ignoring non-zero refcount. Use with care.
|
||||
@@ -247,10 +247,6 @@ class ObjRef : public AnyObjRef {
|
||||
ObjRef(const ObjRef& other) : AnyObjRef(nullptr) {
|
||||
Assign(other);
|
||||
}
|
||||
ObjRef& operator=(const ObjRef& other) {
|
||||
Assign(other);
|
||||
return *this;
|
||||
}
|
||||
void Assign(const ObjRef<T>& other) {
|
||||
AnyObjRef::Assign(other);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void ReturnByValue(ObjRef<List> value) {
|
||||
}
|
||||
|
||||
ObjRef<List> ReturnByRef(ArenaContainer* container) {
|
||||
auto result = ObjRef<List>::Alloc(container);
|
||||
ObjRef<List> result(ObjRef<List>::Alloc(container));
|
||||
result.at<int, data_offset>().set(30);
|
||||
return result;
|
||||
}
|
||||
@@ -88,18 +88,18 @@ void test_placer() {
|
||||
// Pass by reference.
|
||||
while (!cur.null()) {
|
||||
UpdateElement(cur);
|
||||
cur = cur.at<ObjRef<List>, next_offset>().get();
|
||||
cur.Assign(cur.at<ObjRef<List>, next_offset>().get());
|
||||
}
|
||||
// Pass by value.
|
||||
while (!cur.null()) {
|
||||
// We could place clone on stack as well.
|
||||
DoNotUpdateElement(cur.Clone(&heap));
|
||||
cur = cur.at<ObjRef<List>, next_offset>().get();
|
||||
cur.Assign(cur.at<ObjRef<List>, next_offset>().get());
|
||||
}
|
||||
cur = head;
|
||||
while (!cur.null()) {
|
||||
printf("next is %d\n", cur.at<int, data_offset>().get());
|
||||
cur = cur.at<ObjRef<List>, next_offset>().get();
|
||||
cur.Assign(cur.at<ObjRef<List>, next_offset>().get());
|
||||
}
|
||||
}
|
||||
heap.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user