Commit graph

171 commits

Author SHA1 Message Date
Peter Alexander
9d8c78d180 Changed foreach to for to avoid copies + cleanup 2012-12-30 17:15:09 +00:00
Peter Alexander
d24519ee47 More improvements and optimisations to array.join 2012-12-28 17:29:43 +00:00
Peter Alexander
83cf1854db Fix for non-array separators for non-string RoR. 2012-12-27 17:57:29 +00:00
Peter Alexander
221ea836fa Convert sep to array for performance/generality. 2012-12-27 16:38:26 +00:00
Peter Alexander
b6c9ffed91 Fix for mismatched string types + added unittests. 2012-12-27 02:06:06 +00:00
Peter Alexander
ceda4e2880 std.array.join refactor.
tl;dr: std.array.join was quite complicated: 6 implementation functions, and a few hundred lines of code. Now it is just 2 functions, ~120 lines of code smaller, and within 10% performance of original (faster in some cases).

The original had 6 implementations: 3 joins with a separator, 3 without. For each, those 3 consisted of:
* A general slow version (uses `std.algorithm.joiner` with `appender`).
* A version for a range of arrays where you know the length (pre-allocates the destination array then uses array ops).
* A version for a range of arrays where you don't know the length (uses `appender`).

There's no need for the second version because you can just use appender and `.reserve` the size upfront. Appender already uses array ops when available in its `put` function.

There's also no need for the first function because using `joiner` is slower than just looping through the sub-ranges, appending them. The third function doesn't even use the fact that its operating on a range of arrays, so it can easily be merged with the first and second.

The end result is just one function for join with a separator, and one for a join without. They both use `appender`, and have a static branch that will `.reserve` the required size when the information is available.
2012-12-26 18:46:22 +00:00
Peter Alexander
25abd874d1 Simplified std.array.join with separator.
Previously, std.array.join with a separator would check whether it needed to add the separator on each iteration of the loop. With this change, the check is unnecessary because the first element is appended before the loop, then the loop just adds the separator and next element each iteration.

This improves the code significantly in the case of a non-forward RoR because we don't need to know the length anymore. It's simpler, and will be slightly faster.
2012-12-25 19:20:15 +00:00
Dmitry Olshansky
9e35a4d8ee address review remarks 2012-12-13 20:48:24 +04:00
Dmitry Olshansky
222c803536 re-style and fix indention 2012-12-13 20:41:21 +04:00
Dmitry Olshansky
b7286e7444 generalize countLength 2012-12-13 20:41:20 +04:00
Dmitry Olshansky
96a22304d8 another -property error 2012-12-13 20:41:20 +04:00
Dmitry Olshansky
016a55a561 structs with postblit, CTFE, fix -property 2012-12-13 20:41:19 +04:00
Dmitry Olshansky
14e457b37d fix issue 4489 std.array.insert is slow 2012-12-13 20:41:19 +04:00
jmdavis
74f8c844fe Revert "Add alias opDollar and use $ in range slicing"
This reverts commit 07104b5fe6.

As we cannot currenly rely on even ranges with slicing implementing
opDollar, this change breaks code, because it assumes that such ranges
implement opDollar.
2012-12-09 17:21:37 -08:00
Alex Rønne Petersen
c850e68b03 Merge pull request #930 from epi/master
Added assocArray()
2012-12-09 11:33:59 -08:00
k-hara
07104b5fe6 Add alias opDollar and use $ in range slicing 2012-12-05 10:13:17 +09:00
k-hara
28dedee456 Issue 7444 - Require [] for array copies too 2012-11-20 17:55:21 +09:00
Jonathan M Davis
1536320ca1 Merge pull request #905 from monarchdodra/strip
strip and sameTail
2012-11-15 22:46:33 -08:00
Adrian Matoga
383f77c5ce fixed misleading doc for assocArray() 2012-11-14 11:02:27 +00:00
Adrian Matoga
908c1763e1 cleaner template constraints for assocArray() 2012-11-06 11:53:45 +00:00
Adrian Matoga
908680f6d4 Added assocArray() 2012-11-06 10:55:20 +00:00
Andrej Mitrovic
6f65897a6a Add comment about overlap being undocumented on purpose. 2012-11-02 15:10:49 +01:00
monarch dodra
b04b0695a3 Unittests for sameHead/sameTail 2012-10-28 11:54:33 +01:00
monarch dodra
efed1a0e36 Adding sameTail 2012-10-28 11:54:32 +01:00
monarch dodra
425c9d2b9f Allow R values with sameHead
Not much point in passing arrays by const ref when you can just pass by copy.
2012-10-28 11:16:28 +01:00
monarch dodra
8cb3c314d0 remove ctfe check in popFront!NarrowString 2012-10-16 12:56:08 +03:00
jmdavis
735c2adbda Changes required for issue# 6277. 2012-07-21 01:57:28 -07:00
Andrei Alexandrescu
70dcb958ea Merge pull request #661 from jmdavis/popFront
Performance improvements for popFront and narrow strings.
2012-07-15 20:35:09 -07:00
nazriel
f942906396 Runnable examples - std.array 2012-07-15 20:07:32 +00:00
Denis Shelomovskij
64f93b970a Replace typeof(<type>.init[0]) with templates
* ElementEncodingType (12)
* ElementType(1)
2012-07-11 12:58:40 -07:00
jmdavis
02931eb501 Revert "Merge pull request #664 from denis-sh/add-ArrayTarget-template"
This reverts commit f4d0a49493, reversing
changes made to 3cb69914c5.

The merging of request #664 was accidental, and it should not have been
merged. See https://github.com/D-Programming-Language/phobos/pull/664
for details.
2012-07-11 11:49:28 -07:00
k-hara
d6ffbd1328 Add const attribute more strictly 2012-07-11 01:02:59 +09:00
Denis Shelomovskij
00c0d61403 Replace typeof(<type>.init[0]) with templates
* ArrayTarget (12)
2012-07-06 13:38:06 +04:00
Denis Shelomovskij
ea6c9be477 Replace typeof(<type>.init[0]) with templates
* ElementEncodingType (12)
* ElementType(1)
2012-07-06 13:27:07 +04:00
jmdavis
cc1c2429ef Performance improvements for popFront and narrow strings. 2012-07-05 02:42:08 -07:00
jmdavis
5c3d219931 Fix for issue# 8233.
std.array.array fails to compile with ranges of immutable elements which have a length property
2012-06-13 01:44:25 -07:00
Jonathan M Davis
b6ddd05727 Merge pull request #617 from jmdavis/8187
Fix for issue# 8187.
2012-06-10 20:41:17 -07:00
jmdavis
4b5b11450d Slight tweak to save line count. 2012-06-04 00:48:27 -07:00
Dmitry Olshansky
92defbb4a0 save on line count 2012-06-04 11:42:47 +04:00
Dmitry Olshansky
b823cf6731 replaceInto baseline & unittest 2012-06-04 11:37:08 +04:00
jmdavis
453a6822c7 Fix for issue# 8187. 2012-06-02 22:57:04 -07:00
Brad Roberts
487fa80642 Merge pull request #582 from jmdavis/array
Improve the const-correctness of Appender and RefAppender.
2012-05-26 12:01:16 -07:00
jmdavis
1a4e2892b6 Removed deprecated functions which were to be removed in May 2012. 2012-05-23 00:51:12 -07:00
jmdavis
cc17f794e7 Improve the const-correctness of Appender and RefAppender. 2012-05-13 02:36:25 -07:00
k-hara
348f68a159 Add @property more 2012-03-19 21:28:18 +09:00
Brad Roberts
74d1eaf6d1 fix case of variable shadowing in unittest 2012-02-06 21:54:59 -08:00
Andrei Alexandrescu
ae112b9dea Merge pull request #314 from NilsBossung/bugzilla6874
(bugzilla 6874) disable the broken optimized path and fall back to append
2012-01-09 07:51:21 -08:00
k-hara
17e87a472d Revert "Revert "Merge pull request #284 from 9rnsr/fix6208_on_inout""
This reverts commit fef20ede25.
2011-12-15 17:34:09 +09:00
Nils Boßung
5b9080e048 use .capacity 2011-12-06 22:30:42 +01:00
Nils Boßung
2fe6930f27 remove the broken optimization completely 2011-12-06 22:29:41 +01:00