aboutsummaryrefslogtreecommitdiff
path: root/src/lib/_str.rs
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-11-09 14:15:07 -0800
committerGraydon Hoare <[email protected]>2010-11-09 14:15:07 -0800
commit89946609f2de815ea87df3b001fff0caf9efa0d5 (patch)
tree0945861dddd480b822827d77205f90584d0c2586 /src/lib/_str.rs
parentAdd a check for binding an alias. Good thing, as we had two instances in our ... (diff)
downloadrust-89946609f2de815ea87df3b001fff0caf9efa0d5.tar.xz
rust-89946609f2de815ea87df3b001fff0caf9efa0d5.zip
Support a special const-value refcount, use it for const strings.
Diffstat (limited to 'src/lib/_str.rs')
-rw-r--r--src/lib/_str.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs
index 0fc7b373..4ea5ca28 100644
--- a/src/lib/_str.rs
+++ b/src/lib/_str.rs
@@ -97,8 +97,13 @@ fn from_bytes(vec[u8] v) : is_utf8(v) -> str {
}
fn refcount(str s) -> uint {
- // -1 because calling this function incremented the refcount.
- ret rustrt.refcount[u8](s) - 1u;
+ auto r = rustrt.refcount[u8](s);
+ if (r == dbg.const_refcount) {
+ ret r;
+ } else {
+ // -1 because calling this function incremented the refcount.
+ ret r - 1u;
+ }
}