summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-19 13:01:49 -0700
committerbors <bors@rust-lang.org>2014-03-19 13:01:49 -0700
commit4ca51aeea7187a63b987129d67cf7d348b6c60a9 (patch)
tree6f69d3906c3cf940d17fcdd3c56ff73fe099c88d /src/libsyntax/ext
parent7532d20a17dce417e9040e31623e7fcf01971db7 (diff)
parentc04d4846f2a7a49e592f4e98f3e604851d600d4e (diff)
downloadrust-4ca51aeea7187a63b987129d67cf7d348b6c60a9.tar.gz
rust-4ca51aeea7187a63b987129d67cf7d348b6c60a9.zip
auto merge of #12770 : eddyb/rust/drop-tld, r=cmr
Sadly, this seems to make memory usage worse (unless `Vec<T>` makes it worse and this PR doesn't change that much, which is entirely possible).
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/mtwt.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs
index 4d96dd75990..b04e1dfd8b5 100644
--- a/src/libsyntax/ext/mtwt.rs
+++ b/src/libsyntax/ext/mtwt.rs
@@ -126,6 +126,15 @@ pub fn display_sctable(table: &SCTable) {
     }
 }
 
+/// Clear the tables from TLD to reclaim memory.
+pub fn clear_tables() {
+    with_sctable(|table| {
+        *table.table.borrow_mut().get() = Vec::new();
+        *table.mark_memo.borrow_mut().get() = HashMap::new();
+        *table.rename_memo.borrow_mut().get() = HashMap::new();
+    });
+    with_resolve_table_mut(|table| *table = HashMap::new());
+}
 
 // Add a value to the end of a vec, return its index
 fn idx_push<T>(vec: &mut Vec<T> , val: T) -> u32 {