Skip to content

Instantly share code, notes, and snippets.

@oyvindln
Last active August 11, 2017 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oyvindln/3d9c074f22e249f15d7e3f89267e0310 to your computer and use it in GitHub Desktop.
Save oyvindln/3d9c074f22e249f15d7e3f89267e0310 to your computer and use it in GitHub Desktop.
rust vs cpp diff
// clang++ -S -std=c++11 -emit-llvm -vec.cpp -o vec_cpp.ll
// lines: 891
// ( wc -l vec_cpp.ll )
// with stripped blank lines and comments:
// ( sed '/^\s*;/d;/^\s*$/d' vec_cpp.ll | wc -l )
// 698
#include <cinttypes>
#include <vector>
int main(int, char* []) {
auto v = std::vector<int32_t>(0, 100);
for (auto n : v) {
}
}
// rustc +nightly --emit llvm-ir vec.rs -o vec_rust.ll
// lines: 4634
// ( wc -l vec_rust.ll )
// with stripped blank lines and comments:
// ( sed '/^\s*;/d;/^\s*$/d' vec_rust.ll | wc -l )
// 3523
fn main() {
let v = vec![0i32;100];
for n in v {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment