Commit graph

99 commits

Author SHA1 Message Date
jmdavis
038e30c737 Minor adjustment to better workaround bug# 8521.
Apparently, using the ternary operator makes it worse, so I switched it
to use if instead. The semantics are identical.
2012-08-22 02:26:21 -07:00
jmdavis
3ccbcbaff3 Made spacing of if consistent with string, strideBack, and decode. 2012-08-19 18:54:40 -07:00
jmdavis
a60025bb70 Changes for Andrei's comments on pull request# 743. 2012-08-18 14:03:59 -07:00
jmdavis
ad177d0cf1 Workaround for bug# 8521. 2012-08-08 12:43:56 -07:00
jmdavis
4ca0af8662 Made it so that decode works with arbitrary ranges of code units.
I also added decodeFront which operates on the first code point in the
range (unlike stride and strideBack, it requires a different name, since
the signatures of decode and decodeFront are almost identical - the only
difference being that decode takes the index by ref, and decodeFront
takes it as out).
2012-08-07 00:41:18 -07:00
jmdavis
b45e37139e Made it so that strideBack works with arbitrary ranges of code units.
I also added overloads for strideBack which don't require an index
(they operates on the last code point).
2012-08-07 00:38:11 -07:00
jmdavis
acc72035a0 Made it so that stride works with arbitrary ranges of code units.
I also added overloads for stride which don't require an index (they
operate on index 0).
2012-08-07 00:37:50 -07:00
k-hara
119f7f7424 Revert all const qualifier of class member functions that inherited from Object.
This change is necessary to avoid breaking existing codes which inherit them in user code.
2012-07-31 10:05:59 +09: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
dawg
5b7033aef2 make stride trusted
- no bounds check in release mode
2012-07-11 06:08:05 +02:00
dawg
6baf866a95 use faster pass by ref for l-values 2012-07-11 06:07:13 +02:00
Andrei Alexandrescu
408496e160 Merge pull request #680 from 9rnsr/strict_const
Add const attribute more strictly
2012-07-10 11:18:46 -07:00
k-hara
d6ffbd1328 Add const attribute more strictly 2012-07-11 01:02:59 +09:00
dawg
01e4ee175a bsr can always be provided by core.bitop 2012-07-10 10:25:22 +02:00
David Simcha
f4d0a49493 Merge pull request #664 from denis-sh/add-ArrayTarget-template
Add array target template
2012-07-08 13:08:27 -07:00
jmdavis
7514e0322a Fixed deprecations, since we had no release in June. 2012-07-06 22:15:53 -07:00
Denis Shelomovskij
ea6c9be477 Replace typeof(<type>.init[0]) with templates
* ElementEncodingType (12)
* ElementType(1)
2012-07-06 13:27:07 +04:00
jmdavis
d683d13e1c Added codeLength which works with a full string. 2012-06-30 22:39:13 -07:00
Brad Anderson
05b8ec7872 Use toUTFz's better description for toStringz
Also fix typo.
2012-06-13 11:46:18 -06:00
jmdavis
69a221b9ee Changed toUTFz to use an outer template.
It's easier to define aliases this way. I created two templates though
so that you can still pass both template arguments if you want to, and
it'll avoid breaking any code.
2012-03-14 00:28:48 -07:00
jmdavis
a58e19bc27 Change toUTF16z to use toUTFz. 2012-03-13 21:54:16 -07:00
dawg
e782771008 code review changes 2012-03-08 22:51:05 -08:00
dawg
8599d6b4ac optimize std.utf.stride
- templatize functions so that short paths can be inlined
- replace table lookup with bit scan
2012-03-08 22:51:05 -08:00
Daniel Murphy
983349625f This only works because of a bug in dmd, and it was probably supposed to be a char literal. 2012-02-21 15:51:35 +11:00
KennyTM~
bb05d579a2 Add 'pure' attribute to toUTF8, toUTF16 & toUTF32. 2012-02-06 04:56:26 +08:00
dawg
1b0edb728c optimize std.utf.decode
- Use fast path tests for non-complex unicode sequences that can be
   inlined. These rely on the built-in array bounds check.

 - Factor out complex cases into separate functions that do exception
   based validity checks.  The char[] and wchar[] versions use
   pointers to avoid redundant array bounds checks, thus they can only
   be trusted.

 - Complete rewrite of decode for char[] to use less branching and
   unrolled loops. This requires less registers AND less instructions.
   The overlong check is done much cheaper on the code point.

 - The decode functions were made templates to short circuit the very
   restricted function inlining possibilities.
2011-11-07 07:16:37 +01:00
jmdavis
256976dddd Removed "scheduled for deprecation" pragmas.
The pragmas have not been as effective as we might have liked, since
they only work with templates and can't tell you where in your code you
need to make changes, and they seemed to have been more annoying to
programmers than helpful, so we're going to discontinue them. We'll
leave them in for stuff that's actually been deprecated until deprecated
has been improved enough to take a message, but we'll leave "scheduled
for deprecation" messages to the documentation and changelog.
2011-10-23 23:11:17 -07:00
jmdavis
f0af275440 Unscheduled toUTF16z for deprecation.
It's pretty clear from discussions on the newsgroup that we want to keep
toUTF16z, so it shouldn't be scheduled for deprecation anymore. That
change is part of https://github.com/D-Programming-Language/phobos/pull/279 ,
but for whatever reason that pull request hasn't been reviewed yet, let
alone merged in, and this change shouldn't need review, _and_ it should
be in before the next release, so I'm just making it and checking it in.
It's simply removing the "scheduled for deprecation" note in the
documentation and its associated pragma.
2011-10-22 15:24:39 -07:00
jmdavis
5a3739f92d Made std.utf use enforce and enforceEx where applicable. 2011-09-26 22:40:22 -07:00
jmdavis
ea2da771d0 Applied some of the suggestions from the review comments. 2011-09-26 22:18:18 -07:00
jmdavis
b9b8337ccd Renamed UtfException to UTFException to match other uses of UTF.
I created an alias for UtfException and scheduled it for deprecation
(with a fairly short time to deprecation given that it's a simple
renaming).
2011-09-26 22:18:18 -07:00
jmdavis
37ed7a8c25 Fixed UtfException's sequence so that it's uint[4] again. 2011-09-26 22:18:18 -07:00
jmdavis
2ecabfce51 Cleaned up std.utf.
The main purpose of these changes was to make as much as possible in
std.utf pure (other than toUTFx, which I'll be replacing with toUTF in a
future pull request), but I also ended up doing a fair bit of
documentation cleanup. Almost everything in std.utf is pure now though,
which should help considerably in making it possible to make
string functions pure.
2011-09-26 22:18:18 -07:00
jmdavis
41b9078cbf Fix Windows unit tests. 2011-08-15 20:42:10 -07:00
jmdavis
7eee94d2a8 Fix Windows build. 2011-08-15 03:24:29 -07:00
jmdavis
d41b8d939e Scheduled toUTF16z for deprecation. 2011-08-14 19:24:33 -07:00
jmdavis
25cf1cb1fa Attempt at improving warning on toUTFz.
I also put @system on the two overloads of toUTFZ which do pointer
arithmetic. They're obviously @system anyway, but tagging them with it
makes it clearer.
2011-07-12 22:34:58 -07:00
jmdavis
5e79789e01 Merge branch 'master' into utfz 2011-07-10 03:38:54 -07:00
jmdavis
1192616696 Changed toUTFz to use ElementEncodingType instead of typeof(str[0]). 2011-07-10 03:37:55 -07:00
jmdavis
6c6a493def Updates to toUTFz per Andrei's suggestions. 2011-07-03 22:57:19 -07:00
jmdavis
f7d8ca569a Improvement to warning in documentation. 2011-06-29 20:32:16 -07:00
jmdavis
3309c9751a Improved toUTFz so that it does less copying.
toUTFz no longer guarantees that the string will remain zero-terminated.
If the string can be zero-terminated but isn't immutable and doesn't
need to be copied to have the requested character pointer type, then it
no longer copies. This means that it's possible to have a string which
is zero-terminated and then stops being zero-terminated if you alter the
character one passed its end, but that's not likely to be an issue in
most cases, and a note in the documentation points it out so that
programmers can know about it and deal with it appropriately.
2011-06-29 20:10:13 -07:00
jmdavis
595bcb86ba Implemented toUTFz.
I haven't made std.conv.to use it yet, and I haven't touched toUTF16z or
toStringz at all, but here's an implementation for toUTFz. After this is
in, we can make std.conv.to use it when converting to character
pointers, and we should probably make it so that we have toStringz,
toWstringz, and toDstringz which use it and return immutable character
pointers and get rid of toUTF16z.
2011-06-26 02:37:50 -07:00
jmdavis
7de549c1fa Merged master into branch with changes to std.string.
Conflicts:
	changelog.dd
	std/array.d
2011-06-22 21:38:17 -07:00
jmdavis
308df18f16 Added an example to std.utf.codeLength. 2011-06-21 19:36:01 -07:00
jmdavis
1684abf962 Revert "Fixed codeLength fatal misprint."
This reverts commit 1fc3a08fcb.
2011-06-21 19:22:33 -07:00
Denis
1fc3a08fcb Fixed codeLength fatal misprint. 2011-06-21 10:35:45 -07:00
jmdavis
0e1afe82cb Improved std.string.indexOf and std.string.lastIndexOf.
indexOf and lastIndexOf should not work properly with unicode for all
string types (unlike before). As part of that, I also ended up fixing a
bug in std.array.back for strings (wstrings in particular were broken).
I also improved various, related unit tests.
2011-06-12 16:59:50 -07:00
blackwhale
903738f786 another attempt at stride/strideBack 2011-05-27 18:50:14 +04:00