On 21.09.2011 4:04, Timon Gehr wrote:
On 09/21/2011 01:57 AM, Christophe wrote:
Jonathan M Davis , dans le message (digitalmars.D.learn:29637), a
écrit :
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
On 9/20/11, Jonathan M Davisjmdavisp...@gmx.com wrote:
Or
On 09/21/2011 02:15 AM, Christophe wrote:
Timon Gehr , dans le message (digitalmars.D.learn:29641), a écrit :
Last point: WalkLength is not optimized for strings.
std.utf.count should be.
This short implementation of count was 3 to 8 times faster than
walkLength is a simple benchmark:
size_t
On 09/21/2011 12:37 PM, Dmitry Olshansky wrote:
On 21.09.2011 4:04, Timon Gehr wrote:
On 09/21/2011 01:57 AM, Christophe wrote:
Jonathan M Davis , dans le message (digitalmars.D.learn:29637), a
écrit :
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
On 9/20/11, Jonathan M
Actually, I don't buy it. I guess the reason it's faster is that it
doesn't check if the codepoint is valid.
Why should it ? The documentation of std.utf.count says the string must
be validly encoded, not that it will enforce that it is.
Checking a string is valid everytime you use it would
On 21.09.2011 01:57, Christophe wrote:
size_t myCount(string text)
{
size_t n = text.length;
for (uint i=0; itext.length; ++i)
{
auto s = text[i]6;
n -= (s1) - ((s+1)2);
}
return n;
}
Here is a more readable and a bit faster version on dmd windows:
size_t
On 21.09.2011 18:47, Christophe wrote:
Actually, I don't buy it. I guess the reason it's faster is that it
doesn't check if the codepoint is valid.
Why should it ? The documentation of std.utf.count says the string must
be validly encoded, not that it will enforce that it is.
Checking a string
On 21.09.2011 19:12, Christophe Travert wrote:
Nice. It is better with gdc linux 64bits too. I wanted to avoid
conditional expressions like ?: but it's actually slightly faster that
way.
It is not compiled in as conditional jump.
Hi,
I want something like:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
...
I get the wchar[] stuff not working. I am struggling
with pointer to array. Could you give some advice?
Kind regards
Andre
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
I am not familiar with pointers. I know I have to
call
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
I am not familiar with
Are you sure that the call requires the string to be null terminated? I
do not know that winapi function, but this might work:
bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...
It doesn't need to be null-terminated
On 09/20/2011 08:34 PM, Trass3r wrote:
Are you sure that the call requires the string to be null terminated?
I do not know that winapi function, but this might work:
bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...
On 09/20/2011 08:24 PM, Timon Gehr wrote:
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a
Am Tue, 20 Sep 2011 20:44:40 +0200 schrieb Timon Gehr:
On 09/20/2011 08:24 PM, Timon Gehr wrote:
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
Don't use length, use std.utf.count, ala:
import std.utf;
alias toUTFz!(const(wchar)*, string) toUTF16z;
GetTextExtentPoint32W(str.toUTF16z, std.utf.count(str), s);
I like to keep that alias for my code since I was already using it beforehand.
I'm pretty sure (ok maybe 80% sure) that
On 9/20/11, Jonathan M Davis jmdavisp...@gmx.com wrote:
Or std.range.walkLength. I don't know why we really have std.utf.count. I
just
calls walkLength anyway. I suspect that it's a function that predates
walkLength and was made to use walkLength after walkLength was introduced.
But
it's
One other thing, count can only take an array which seems too
restrictive since walkLength can take any range at all. So maybe count
should be just an alias to walkLength or it should possibly be removed
(I'm against fully removing it because I already use it in code and I
think the name does make
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
On 9/20/11, Jonathan M Davis jmdavisp...@gmx.com wrote:
Or std.range.walkLength. I don't know why we really have std.utf.count. I
just
calls walkLength anyway. I suspect that it's a function that predates
walkLength and was made
On 9/20/11, Jonathan M Davis jmdavisp...@gmx.com wrote:
We specifically avoid having aliases in Phobos simply for having alternate
function names. Aliases need to actually be useful, or they shouldn't be
there.
And function names have to be useful to library users. walkLength is
an awful name
Jonathan M Davis , dans le message (digitalmars.D.learn:29637), a
écrit :
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
On 9/20/11, Jonathan M Davis jmdavisp...@gmx.com wrote:
Or std.range.walkLength. I don't know why we really have std.utf.count. I
just
calls walkLength
Timon Gehr , dans le message (digitalmars.D.learn:29641), a écrit :
Last point: WalkLength is not optimized for strings.
std.utf.count should be.
This short implementation of count was 3 to 8 times faster than
walkLength is a simple benchmark:
size_t myCount(string text)
{
size_t n =
22 matches
Mail list logo