Skip to content

Conversation

@stevengj
Copy link
Member

@stevengj stevengj commented Jan 3, 2017

This adds a small optimization to inline string literals in dot calls. i.e. f.("foo", bar) becomes broadcast(x -> f("foo", x), bar) rather than broadcast((y,x) -> f(y, x), "foo", bar). In a small benchmark of ["a" for i = 1:1000] .* "b", it led to about a 50% speedup.

@stevengj stevengj added the broadcast Applying a function over a collection label Jan 3, 2017
@stevengj
Copy link
Member Author

stevengj commented Jan 3, 2017

Test failure is an inference thing. Boils down to:

julia> Base.REPLCompletions.get_type(:([""] .== ""), Main)
(Any,false)

when it should give (BitArray{1},true).

@stevengj
Copy link
Member Author

stevengj commented Jan 7, 2017

Since the get_type function cannot get the return type of anonymous function evaluation, e.g Base.REPLCompletions.get_type(:((x -> x+1)(1)), Main) gives (Any,false), I think that there's not much point in expecting it to handle dot calls in general.

…o handle dot calls now that they generate anonymous functions
# powerful enough to analyze general dot calls because it can't handle
# anonymous-function evaluation.)
# s = "CompletionFoo.test5(push!(Base.split(\"\",' '),\"\",\"\").==\"\","
# c, r, res = test_complete(s)
Copy link
Contributor

Choose a reason for hiding this comment

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

does this error or should these be @test_broken ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I forgot about the @test_broken macro.

@stevengj
Copy link
Member Author

stevengj commented Jan 9, 2017

Okay to merge?

@p-zubieta
Copy link
Contributor

Can we test that is really being inlined? As in here

@stevengj
Copy link
Member Author

stevengj commented Jan 9, 2017

Added a test for inlining.

@stevengj
Copy link
Member Author

Ready to merge.

@StefanKarpinski StefanKarpinski merged commit 46c2708 into JuliaLang:master Jan 12, 2017
@stevengj stevengj deleted the inlinestrings branch January 12, 2017 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

broadcast Applying a function over a collection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants