Browse Source

Improved GC and added a GC pass to the shell

master
Ludovic 'Archivist' Lagouardette 6 years ago
parent
commit
776ee87caa
3 changed files with 22 additions and 0 deletions
  1. +1
    -0
      .gitignore
  2. +20
    -0
      crank.h
  3. +1
    -0
      main.cpp

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
a.out

+ 20
- 0
crank.h View File

@ -289,6 +289,26 @@ public:
void collect()
{
auto elems = &elements;
while(elems->ptr)
{
auto elems_after = &(elems->ptr->next);
while(elems_after->ptr)
{
if(
elems->ptr->data.first == elems_after->ptr->data.first
)
{
*elems_after = std::move(elems_after->ptr->next);
}
else
{
elems_after = &(elems_after->ptr->next);
}
}
elems = &(elems->ptr->next);
}
auto cps = &copies;
while(cps->ptr)
{

+ 1
- 0
main.cpp View File

@ -30,6 +30,7 @@ int main()
for(auto c : ret)
std::cout<<c;
std::cout<<std::endl<<"> ";
ctx.collect();
}
}

Loading…
Cancel
Save