Skip to content
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

more efficient repeat(Char, n) #23787

Merged
merged 2 commits into from
Sep 20, 2017
Merged

more efficient repeat(Char, n) #23787

merged 2 commits into from
Sep 20, 2017

Conversation

StefanKarpinski
Copy link
Member

No description provided.

@stevengj
Copy link
Member

stevengj commented Sep 20, 2017

Note that I've literally never seen any usage of this function except for ASCII chars. (Mainly, it seems to be used to create strings of spaces.) And even those uses are usually in I/O where the string-creation is not performance-critical. So I'm not sure it's worth the added complexity to make 'α'^n slightly more efficient.

@stevengj stevengj added the performance Must go faster label Sep 20, 2017
@test_throws ArgumentError repeat(S, -1)
@test repeat(c, 0) == ""
@test repeat(s, 0) == ""
@test repeat(S, 0) == ""
Copy link
Member

Choose a reason for hiding this comment

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

Might be clearer to collapse some of these tests into a single line, e.g.

@test c^0 == s^0 == S^0 == ""
@test c^1 == s^1 == s

@StefanKarpinski StefanKarpinski merged commit 9202df2 into master Sep 20, 2017
@StefanKarpinski StefanKarpinski deleted the sk/repeatchar branch September 20, 2017 13:55
@JeffBezanson
Copy link
Member

At this point it would be nice to factor out utf-8 encoding somehow --- we have several copies of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants