Skip to content

Commit

Permalink
Merge branch 'master' into release-0.5.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagician committed Oct 28, 2024
2 parents b6d5082 + ed2cf48 commit 0ea0f92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Pending
- [\#47](https://github.com/arkworks-rs/std/pull/47) Fix incorrect use of atomic variable in `src/perf_trace.rs`

### Breaking changes

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub use num_traits::{One, Zero};
/// assert_eq!(log2(1 << 15), 15);
/// assert_eq!(log2(2usize.pow(18)), 18);
/// ```
pub fn log2(x: usize) -> u32 {
#[inline(always)]
pub const fn log2(x: usize) -> u32 {
if x == 0 {
0
} else if x.is_power_of_two() {
Expand Down
8 changes: 3 additions & 5 deletions src/perf_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ pub mod inner {

let msg = $msg();
let start_info = "Start:".yellow().bold();
let indent_amount = 2 * NUM_INDENT.fetch_add(0, Ordering::Relaxed);
let indent_amount = 2 * NUM_INDENT.fetch_add(1, Ordering::Relaxed);
let indent = compute_indent(indent_amount);

$crate::perf_trace::println!("{}{:8} {}", indent, start_info, msg);
NUM_INDENT.fetch_add(1, Ordering::Relaxed);
$crate::perf_trace::TimerInfo {
msg: msg.to_string(),
time: Instant::now(),
Expand Down Expand Up @@ -110,8 +109,7 @@ pub mod inner {
let end_info = "End:".green().bold();
let message = format!("{} {}", $time.msg, $msg());

NUM_INDENT.fetch_sub(1, Ordering::Relaxed);
let indent_amount = 2 * NUM_INDENT.fetch_add(0, Ordering::Relaxed);
let indent_amount = 2 * NUM_INDENT.fetch_sub(1, Ordering::Relaxed);
let indent = compute_indent(indent_amount);

// Todo: Recursively ensure that *entire* string is of appropriate
Expand Down Expand Up @@ -144,7 +142,7 @@ pub mod inner {
let start_indent_amount = 2 * NUM_INDENT.fetch_add(0, Ordering::Relaxed);
let start_indent = compute_indent(start_indent_amount);

let msg_indent_amount = 2 * NUM_INDENT.fetch_add(0, Ordering::Relaxed) + 2;
let msg_indent_amount = start_indent_amount + 2;
let msg_indent = compute_indent_whitespace(msg_indent_amount);
let mut final_message = "\n".to_string();
for line in $msg().lines() {
Expand Down

0 comments on commit 0ea0f92

Please sign in to comment.