Skip to content

Commit ebd6665

Browse files
committed
libsyntax: Remove the interner_get function and all uses
1 parent 1165794 commit ebd6665

File tree

5 files changed

+13
-34
lines changed

5 files changed

+13
-34
lines changed

src/libsyntax/ast.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use codemap::{Span, Spanned, DUMMY_SP};
1414
use abi::AbiSet;
1515
use ast_util;
1616
use opt_vec::OptVec;
17-
use parse::token::{InternedString, interner_get, special_idents};
18-
use parse::token::{str_to_ident};
17+
use parse::token::{InternedString, special_idents, str_to_ident};
18+
use parse::token;
1919

2020
use std::cell::RefCell;
2121
use std::hashmap::HashMap;
@@ -126,7 +126,8 @@ pub type Mrk = u32;
126126

127127
impl<S:Encoder> Encodable<S> for Ident {
128128
fn encode(&self, s: &mut S) {
129-
s.emit_str(interner_get(self.name));
129+
let string = token::get_ident(self.name);
130+
s.emit_str(string.get());
130131
}
131132
}
132133

src/libsyntax/ast_util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ use std::num;
2525

2626
pub fn path_name_i(idents: &[Ident]) -> ~str {
2727
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
28-
idents.map(|i| token::interner_get(i.name)).connect("::")
28+
idents.map(|i| {
29+
let string = token::get_ident(i.name);
30+
string.get().to_str()
31+
}).connect("::")
2932
}
3033

3134
// totally scary function: ignores all but the last element, should have

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4184,7 +4184,8 @@ impl Parser {
41844184
outer_attrs, "path") {
41854185
Some(d) => dir_path.join(d),
41864186
None => {
4187-
let mod_name = token::interner_get(id.name).to_owned();
4187+
let mod_string = token::get_ident(id.name);
4188+
let mod_name = mod_string.get().to_owned();
41884189
let default_path_str = mod_name + ".rs";
41894190
let secondary_path_str = mod_name + "/mod.rs";
41904191
let default_path = dir_path.join(default_path_str.as_slice());

src/libsyntax/parse/token.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,6 @@ pub fn gensym(str : &str) -> Name {
651651
interner.gensym(str)
652652
}
653653

654-
// map an interned representation back to a string
655-
pub fn interner_get(name : Name) -> @str {
656-
get_ident_interner().get(name)
657-
}
658-
659654
// maps a string to an identifier with an empty syntax context
660655
pub fn str_to_ident(str : &str) -> ast::Ident {
661656
ast::Ident::new(intern(str))
@@ -679,28 +674,6 @@ pub fn fresh_name(src : &ast::Ident) -> Name {
679674
gensym(format!("{}_{}",ident_to_str(src),num))*/
680675
}
681676

682-
// it looks like there oughta be a str_ptr_eq fn, but no one bothered to implement it?
683-
684-
// determine whether two @str values are pointer-equal
685-
pub fn str_ptr_eq(a : @str, b : @str) -> bool {
686-
unsafe {
687-
let p : uint = cast::transmute(a);
688-
let q : uint = cast::transmute(b);
689-
let result = p == q;
690-
// got to transmute them back, to make sure the ref count is correct:
691-
let _junk1 : @str = cast::transmute(p);
692-
let _junk2 : @str = cast::transmute(q);
693-
result
694-
}
695-
}
696-
697-
// return true when two identifiers refer (through the intern table) to the same ptr_eq
698-
// string. This is used to compare identifiers in places where hygienic comparison is
699-
// not wanted (i.e. not lexical vars).
700-
pub fn ident_spelling_eq(a : &ast::Ident, b : &ast::Ident) -> bool {
701-
str_ptr_eq(interner_get(a.name),interner_get(b.name))
702-
}
703-
704677
// create a fresh mark.
705678
pub fn fresh_mark() -> Mrk {
706679
gensym("mark")

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use codemap::{CodeMap, BytePos};
1919
use codemap;
2020
use diagnostic;
2121
use parse::classify::expr_is_simple_block;
22-
use parse::token::{IdentInterner, interner_get};
22+
use parse::token::IdentInterner;
2323
use parse::{comments, token};
2424
use parse;
2525
use print::pp::{break_offset, word, space, zerobreak, hardbreak};
@@ -1544,7 +1544,8 @@ pub fn print_ident(s: &mut State, ident: ast::Ident) {
15441544
}
15451545

15461546
pub fn print_name(s: &mut State, name: ast::Name) {
1547-
word(&mut s.s, interner_get(name));
1547+
let string = token::get_ident(name);
1548+
word(&mut s.s, string.get());
15481549
}
15491550

15501551
pub fn print_for_decl(s: &mut State, loc: &ast::Local, coll: &ast::Expr) {

0 commit comments

Comments
 (0)