@@ -154,7 +154,8 @@ type crate_ctxt =
154
154
task_type : TypeRef ,
155
155
builder : BuilderRef_res ,
156
156
shape_cx : shape:: ctxt ,
157
- gc_cx : gc:: ctxt } ;
157
+ gc_cx : gc:: ctxt ,
158
+ cstrcache : cstrcache:: t } ;
158
159
159
160
type local_ctxt =
160
161
{ path: [ str ] ,
@@ -842,10 +843,11 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i, False); }
842
843
// This is a 'c-like' raw string, which differs from
843
844
// our boxed-and-length-annotated strings.
844
845
fn C_cstr ( cx : & @crate_ctxt , s : & str ) -> ValueRef {
845
- let sc = llvm:: LLVMConstString ( str:: buf ( s) , str:: byte_len ( s) , False ) ;
846
+ let sc = llvm:: LLVMConstString ( safe_sbuf ( cx, s) ,
847
+ str:: byte_len ( s) , False ) ;
846
848
let g =
847
849
llvm:: LLVMAddGlobal ( cx. llmod , val_ty ( sc) ,
848
- str :: buf ( cx. names . next ( "str" ) ) ) ;
850
+ safe_sbuf ( cx , cx. names . next ( "str" ) ) ) ;
849
851
llvm:: LLVMSetInitializer ( g, sc) ;
850
852
llvm:: LLVMSetGlobalConstant ( g, True ) ;
851
853
llvm:: LLVMSetLinkage ( g, lib:: llvm:: LLVMInternalLinkage as llvm:: Linkage ) ;
@@ -863,10 +865,10 @@ fn C_str(cx: &@crate_ctxt, s: &str) -> ValueRef {
863
865
let box =
864
866
C_struct ( [ C_int ( abi:: const_refcount as int ) , C_int ( len + 1 u as int ) ,
865
867
C_int ( len + 1 u as int ) , C_int ( 0 ) ,
866
- llvm:: LLVMConstString ( str :: buf ( s) , len, False ) ] ) ;
868
+ llvm:: LLVMConstString ( safe_sbuf ( cx , s) , len, False ) ] ) ;
867
869
let g =
868
870
llvm:: LLVMAddGlobal ( cx. llmod , val_ty ( box) ,
869
- str :: buf ( cx. names . next ( "str" ) ) ) ;
871
+ safe_sbuf ( cx , cx. names . next ( "str" ) ) ) ;
870
872
llvm:: LLVMSetInitializer ( g, box) ;
871
873
llvm:: LLVMSetGlobalConstant ( g, True ) ;
872
874
llvm:: LLVMSetLinkage ( g, lib:: llvm:: LLVMInternalLinkage as llvm:: Linkage ) ;
@@ -909,14 +911,18 @@ fn C_shape(ccx: &@crate_ctxt, bytes: &[u8]) -> ValueRef {
909
911
let llshape = C_bytes ( bytes) ;
910
912
let llglobal =
911
913
llvm:: LLVMAddGlobal ( ccx. llmod , val_ty ( llshape) ,
912
- str :: buf ( ccx. names . next ( "shape" ) ) ) ;
914
+ safe_sbuf ( ccx , ccx. names . next ( "shape" ) ) ) ;
913
915
llvm:: LLVMSetInitializer ( llglobal, llshape) ;
914
916
llvm:: LLVMSetGlobalConstant ( llglobal, True ) ;
915
917
llvm:: LLVMSetLinkage ( llglobal,
916
918
lib:: llvm:: LLVMInternalLinkage as llvm:: Linkage ) ;
917
919
ret llvm:: LLVMConstPointerCast ( llglobal, T_ptr ( T_i8 ( ) ) ) ;
918
920
}
919
921
922
+ fn safe_sbuf ( ccx : & @crate_ctxt , s : & str ) -> str:: rustrt:: sbuf {
923
+ cstrcache:: get_cstr ( ccx. cstrcache , s)
924
+ }
925
+
920
926
//
921
927
// Local Variables:
922
928
// mode: rust
0 commit comments