Your reminder that building arrays with reduce, while fun, is accidentally quadratic.pic.twitter.com/5hmrpQkKBS
When you tweet with a location, Twitter stores that location. You can switch location on/off before each Tweet and always have the option to delete your location history. Learn more
Add this Tweet to your website by copying the code below. Learn more
Add this video to your website by copying the code below. Learn more
| Country | Code | For customers of |
|---|---|---|
| United States | 40404 | (any) |
| Canada | 21212 | (any) |
| United Kingdom | 86444 | Vodafone, Orange, 3, O2 |
| Brazil | 40404 | Nextel, TIM |
| Haiti | 40404 | Digicel, Voila |
| Ireland | 51210 | Vodafone, O2 |
| India | 53000 | Bharti Airtel, Videocon, Reliance |
| Indonesia | 89887 | AXIS, 3, Telkomsel, Indosat, XL Axiata |
| Italy | 4880804 | Wind |
| 3424486444 | Vodafone | |
| » See SMS short codes for other countries | ||
This timeline is where you’ll spend most of your time, getting instant updates about what matters to you.
Hover over the profile pic and click the Following button to unfollow any account.
When you see a Tweet you love, tap the heart — it lets the person who wrote it know you shared the love.
The fastest way to share someone else’s Tweet with your followers is with a Retweet. Tap the icon to send it instantly.
Add your thoughts about any Tweet with a Reply. Find a topic you’re passionate about, and jump right in.
Get instant insight into what people are talking about now.
Follow more accounts to get instant updates about topics you care about.
See the latest conversations about any topic instantly.
Catch up instantly on the best stories happening as they unfold.
Your reminder that building arrays with reduce, while fun, is accidentally quadratic.pic.twitter.com/5hmrpQkKBS
@AirspeedSwift @rob_rix Building arrays with reduce and an On append operation is quadratic.
#NotAllBuildngArraysWIthReduce
@raganwald @AirspeedSwift @rob_rix odd. Unless it's list, concat should be O(n) with n=postfix length=1, and no copy should happen. So why?
@an0 Each step of the reduce generates a new Array in Swift, requiring an O(n) copy to be made. @raganwald @AirspeedSwift @rob_rix
@an0 The + operator on Array has to make a copy because Arrays can't do partial sharing like Lists. @raganwald @AirspeedSwift @rob_rix
@cocoaphony @raganwald @AirspeedSwift @rob_rix A + B can not be implemented by mutating A when A is unshared?
@an0 The "A" in this case was passed to the closure. Hard to discover it's unshared. @raganwald @AirspeedSwift @rob_rix
@an0 Not saying it's totally impossible for compiler to detect, but Swift doesn't encourage the pattern. @raganwald @AirspeedSwift @rob_rix
@cocoaphony @an0 @raganwald @AirspeedSwift I think it’s a missed ARC optimization. isUniquelyReferenced() should be able to deal.
@rob_rix @cocoaphony @an0 @raganwald @AirspeedSwift I don't think '+' is implemented to check for unique referencing at all.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.