-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Optimize include_bin! for large inputs #9851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -917,6 +917,24 @@ pub fn C_estr_slice(cx: &mut CrateContext, s: @str) -> ValueRef { | |
} | ||
} | ||
|
||
pub fn C_binary_slice(cx: &mut CrateContext, data: &[u8]) -> ValueRef { | ||
unsafe { | ||
let len = data.len(); | ||
let lldata = C_bytes(data); | ||
|
||
let gsym = token::gensym("binary"); | ||
let g = do format!("binary{}", gsym).with_c_str |buf| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this make something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The call to Regardless, creating strings as statics involves a similar pattern of creating a symbol name. |
||
llvm::LLVMAddGlobal(cx.llmod, val_ty(lldata).to_ref(), buf) | ||
}; | ||
llvm::LLVMSetInitializer(g, lldata); | ||
llvm::LLVMSetGlobalConstant(g, True); | ||
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage); | ||
|
||
let cs = llvm::LLVMConstPointerCast(g, Type::i8p().to_ref()); | ||
C_struct([cs, C_uint(cx, len)], false) | ||
} | ||
} | ||
|
||
pub fn C_zero_byte_arr(size: uint) -> ValueRef { | ||
unsafe { | ||
let mut i = 0u; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,6 +691,7 @@ pub type lit = Spanned<lit_>; | |
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] | ||
pub enum lit_ { | ||
lit_str(@str, StrStyle), | ||
lit_binary(@[u8]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to break rustdoc. See https://github.com/alexcrichton/rust/blob/a8c9b498c1e62db912fa04ffe517d5b18f2a84de/src/librustdoc/clean.rs#L1121. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. I totally ran |
||
lit_char(u32), | ||
lit_int(i64, int_ty), | ||
lit_uint(u64, uint_ty), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice doc change in irrelevant PR ;P