Skip to content

Commit

Permalink
python: micro-optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Dec 4, 2023
1 parent 2f327a3 commit a6ae491
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cmd/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
if rconfig.no_headers {
headers = csv::StringRecord::new();

let mut buffer = itoa::Buffer::new();
for i in 0..headers_len {
headers.push_field(&i.to_string());
headers.push_field(buffer.format(i));
}
} else {
if !args.cmd_filter {
Expand Down Expand Up @@ -305,6 +306,8 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
// Initializing locals
let mut row_data: Vec<&str> = Vec::with_capacity(headers_len);

// assert so the record.get() below skips bounds check
assert!(record.len() == headers_len);
header_vec
.iter()
.enumerate()
Expand All @@ -329,7 +332,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
"Evaluation of given expression failed with the above error!"
})
.unwrap_or(error_result);
.unwrap_or_else(|_| error_result);

if args.cmd_map {
let result = helpers
Expand Down

0 comments on commit a6ae491

Please sign in to comment.