Skip to content

rewrite of shootout-fasta.rs - #10933

Closed
TeXitoi wants to merge 1 commit into
rust-lang:masterfrom
TeXitoi:shootout-fasta-rewrite
Closed

rewrite of shootout-fasta.rs#10933
TeXitoi wants to merge 1 commit into
rust-lang:masterfrom
TeXitoi:shootout-fasta-rewrite

Conversation

@TeXitoi

Copy link
Copy Markdown
Contributor

improvements:

  • no managed box
  • no virtual calls
  • no useless copy
  • optimizations (bisect is slower, limit tests, BufferedWriter...)
  • pass shootout test
  • 10 times faster

@emberian

Copy link
Copy Markdown
Contributor

Please change 'self to 'a or some other name; it is no longer allowed on master.

Comment threadsrc/test/bench/shootout-fasta.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can write this function as:

letmut cum = 0.0;let data = aa.iter().map(|&(ch, p)| { cum += p;(cum, ch asu8)}).collect();AAGen{rng: rng,data: data }

(with line breaking to taste.)

@TeXitoi

Copy link
Copy Markdown
ContributorAuthor

With all the comment and using integer arithmetic for a big speedup (should be about as fast as the best official implementation).

Comment threadsrc/test/bench/shootout-fasta.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this just be LINE_LENGTH + 1?

@TeXitoi

Copy link
Copy Markdown
ContributorAuthor

The previous commit does not include the integer arithmetic, this one is better.

If we want safe code, we can remove it at the cost of 5% here.

@TeXitoi

Copy link
Copy Markdown
ContributorAuthor

Finally, unsafe_set is not visible, but the zip version by @huonw is approx 7% slower. So no unsafe code, but a quite ugly loop with indexing.

improvements:
- no managed box
- no virtual calls
- no useless copy
- optimizations (bisect is slower, limit tests, BufferedWriter...)
- pass shootout test
- should be as fast as the best official test
Thanks to @cmr and @eddyb for their help!
@TeXitoi

Copy link
Copy Markdown
ContributorAuthor

@huonw version discussed in the outdated diff is basically for a in line.mut_iter().zip(it.by_ref()).take(nb) {…. It is 7% slower.

@huonw

Copy link
Copy Markdown
Contributor

(cc @alexcrichton ^, since, iirc, one doesn't get notifications from the main PR after commenting on an individual commit.)

@alexcrichton

Copy link
Copy Markdown
Member

huh, who knew!

bors added a commit that referenced this pull request Dec 14, 2013
…chton
improvements:
- no managed box
- no virtual calls
- no useless copy
- optimizations (bisect is slower, limit tests, BufferedWriter...)
- pass shootout test
- 10 times faster
@borsbors closed this Dec 14, 2013
@TeXitoi
TeXitoi deleted the shootout-fasta-rewrite branch April 21, 2014 22:11
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 30, 2023
[`useless_vec`]: lint on `vec![_]` invocations that adjust to a slice
Fixesrust-lang#2262 (well, actually my PR over at rust-lang#10901 did do most of the stuff, but this PR implements the one last other case mentioned in the comments that my PR didn't fix)
Before this change, it would lint `(&vec![1]).iter().sum::<i32>()`, but not `vec![1].iter().sum::<i32>()`. This PR handles this case.
This also refactors a few things that I wanted to do in my other PR but forgot about.
changelog: [`useless_vec`]: lint on `vec![_]` invocations that adjust to a slice
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
10933: show values of constants in hover r=lnicola a=HKalbasi
Fixrust-lang#8497
cc rust-lang#8655
Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@TeXitoi@emberian@huonw@alexcrichton@bors