Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 21:13, Steven Schveighoffer wrote: > Well, you don't need to use appender for that (and doing so is copying a > lot of the data an extra time). All you need is to extend the pipe until > there isn't any more new data, and it will all be in the buffer. > > // almost the same line from

Re: Is it bad form to put code in package.d other than imports?

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 03, 2018 06:10:10 Soulsbane via Digitalmars-d-learn wrote: > I've only understood that imports should go in package.d. I'm > seeing more and more packages on code.dlang.org using it for the > packages primary code. Is this alright? As far as I can tell it's > just bad form.

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 21:48, Steven Schveighoffer wrote: > On 1/2/18 3:13 PM, Steven Schveighoffer wrote: >> // almost the same line from your current version >> auto mypipe = openDev("../out/nist/2011.json.gz") >>    .bufd.unzip(CompressionFormat.gzip); > > Would you mind telling me the

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Tim Hsu via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 22:49:20 UTC, Adam D. Ruppe wrote: On Tuesday, 2 January 2018 at 22:17:14 UTC, Johan Engelen wrote: Pass the Vector3f by value. This is very frequently the correct answer to these questions! Never assume ref is faster if speed matters - it may not be. However

Re: how to localize console and GUI apps in Windows

2018-01-02 Thread Andrei via Digitalmars-d-learn
On Friday, 29 December 2017 at 11:14:39 UTC, zabruk70 wrote: On Friday, 29 December 2017 at 10:35:53 UTC, Andrei wrote: Though it is not suitable for GUI type of a Windows application. AFAIK, Windows GUI have no ANSI/OEM problem. You can use Unicode. Partly, yes. Just for a test I tried to

Is it bad form to put code in package.d other than imports?

2018-01-02 Thread Soulsbane via Digitalmars-d-learn
I've only understood that imports should go in package.d. I'm seeing more and more packages on code.dlang.org using it for the packages primary code. Is this alright? As far as I can tell it's just bad form. It would be nice to have one of the maintainers higher up the food chain comment on

Re: Efficient way to pass struct as parameter

2018-01-02 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 02, 2018 at 10:17:14PM +, Johan Engelen via Digitalmars-d-learn wrote: [...] > Passing by pointer (ref is the same) has large downsides and is > certainly not always fastest. For small structs and if copying is not > semantically wrong, just pass by value. +1. > More important:

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 22:49:20 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 2 January 2018 at 22:17:14 UTC, Johan Engelen wrote: > > Pass the Vector3f by value. > > This is very frequently the correct answer to these questions! > Never assume ref is faster if speed matters -

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 18:21:13 UTC, Tim Hsu wrote: I am creating Vector3 structure. I use struct to avoid GC. However, struct will be copied when passed as parameter to function struct Ray { Vector3f origin; Vector3f dir; @nogc @system this(Vector3f *origin, Vector3f

Filling up a FormatSpec

2018-01-02 Thread rumbu via Digitalmars-d-learn
Is there any way to parse a format string into a FormatSpec? FormatSpec has a private function "fillUp" which is not accessible. I need to provide formatting capabilities to a custom data type, I've already written the standard function: void toString(C)(scope void delegate(const(C)[])

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/2/18 3:13 PM, Steven Schveighoffer wrote: // almost the same line from your current version auto mypipe = openDev("../out/nist/2011.json.gz")   .bufd.unzip(CompressionFormat.gzip); Would you mind telling me the source of the data? When I do get around to it, I want to

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/2/18 1:01 PM, Christian Köstlin wrote: On 02.01.18 15:09, Steven Schveighoffer wrote: On 1/2/18 8:57 AM, Adam D. Ruppe wrote: On Tuesday, 2 January 2018 at 11:22:06 UTC, Stefan Koch wrote: You can make it much faster by using a sliced static array as buffer. Only if you want data

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 19:27:50 Igor Shirkalin via Digitalmars-d-learn wrote: > On Tuesday, 2 January 2018 at 18:45:48 UTC, Jonathan M Davis > > wrote: > > [...] > > Smart optimizer should think for you without any "auto" private > words if function is inlined. I mean LDC compiler first of

Re: Slices and Dynamic Arrays

2018-01-02 Thread Ali Çehreli via Digitalmars-d-learn
On 01/02/2018 11:17 AM, Jonathan M Davis wrote: > On Tuesday, January 02, 2018 10:37:17 Ali Çehreli via Digitalmars-d-learn > wrote: >> For these reasons, the interface that the program is using is a "slice". >> Dynamic array is a different concept owned and implemented by the GC. > > Except that

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 18:45:48 UTC, Jonathan M Davis wrote: [...] Smart optimizer should think for you without any "auto" private words if function is inlined. I mean LDC compiler first of all.

Re: Slices and Dynamic Arrays

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 10:37:17 Ali Çehreli via Digitalmars-d-learn wrote: > As soon as we call it "dynamic array", I can't help but think "adding > elements". Since GC is in the picture when that happens, it's essential > to think GC when adding an element is involved. > > Further, evident

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Seb via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 18:21:13 UTC, Tim Hsu wrote: I am creating Vector3 structure. I use struct to avoid GC. However, struct will be copied when passed as parameter to function struct Ray { Vector3f origin; Vector3f dir; @nogc @system this(Vector3f *origin, Vector3f

Re: why @property cannot be pass as ref ?

2018-01-02 Thread Ali Çehreli via Digitalmars-d-learn
On 12/29/2017 07:49 PM, ChangLong wrote: On Wednesday, 20 December 2017 at 18:43:21 UTC, Ali Çehreli wrote: Thanks to Mengü for linking to that section. I have to make corrections below. Ali Thanks for explain, Ali And Mengu. What I am try to do is implement a unique data type. (the

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 18:21:13 Tim Hsu via Digitalmars-d-learn wrote: > I am creating Vector3 structure. I use struct to avoid GC. > However, struct will be copied when passed as parameter to > function > > > struct Ray { > Vector3f origin; > Vector3f dir; > > @nogc @system >

Re: Adding Toc for the "longish" spec pages.

2018-01-02 Thread Seb via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:17:47 UTC, Seb wrote: On Friday, 29 December 2017 at 12:13:02 UTC, Mike Franklin wrote: [...] Yes, opening an issue or PR is the best way to move things forward. In this case, this is already on my radar and will happen soon (since a couple of weeks we

Re: Slices and Dynamic Arrays

2018-01-02 Thread Ali Çehreli via Digitalmars-d-learn
First, I'm in complete agreement with Steve on this. I wrote a response to you yesterday, which I decided to not send after counting to ten because despite being much more difficult, I see that your view can also be aggreable. On 01/02/2018 10:02 AM, Jonathan M Davis wrote: > On Tuesday,

Efficient way to pass struct as parameter

2018-01-02 Thread Tim Hsu via Digitalmars-d-learn
I am creating Vector3 structure. I use struct to avoid GC. However, struct will be copied when passed as parameter to function struct Ray { Vector3f origin; Vector3f dir; @nogc @system this(Vector3f *origin, Vector3f *dir) { this.origin = *origin; this.dir =

Re: Get aliased type

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 11:31:28 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 1/2/18 7:45 AM, John Chapman wrote: > > On Tuesday, 2 January 2018 at 12:19:19 UTC, David Nadlinger wrote: > >> There is indeed no way to do this; as you say, aliases are just names > >> for a

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.01.18 15:09, Steven Schveighoffer wrote: > On 1/2/18 8:57 AM, Adam D. Ruppe wrote: >> On Tuesday, 2 January 2018 at 11:22:06 UTC, Stefan Koch wrote: >>> You can make it much faster by using a sliced static array as buffer. >> >> Only if you want data corruption! It keeps a copy of your

Re: Slices and Dynamic Arrays

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 07:53:00 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 1/1/18 12:18 AM, Jonathan M Davis wrote: > > A big problem with the term slice though is that it means more than just > > dynamic arrays - e.g. you slice a container to get a range over it, so > > that

Re: structs inheriting from and implementing interfaces

2018-01-02 Thread Chris M. via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 00:54:13 UTC, Laeeth Isharc wrote: On Friday, 29 December 2017 at 12:59:21 UTC, rjframe wrote: On Fri, 29 Dec 2017 12:39:25 +, Nicholas Wilson wrote: [...] I've actually thought about doing this to get rid of a bunch of if qualifiers in my function

Re: C++ interfaces and D dynamic arrays

2018-01-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-02 17:48, Void-995 wrote: Hi, everyone. I would like to have an interface that can be implemented and/or used from C++ in D. One of the things I would like to keep is the nice feature of D dynamic arrays in terms of bounding checks and "length" property. Let's assume: extern

Re: structs inheriting from and implementing interfaces

2018-01-02 Thread flamencofantasy via Digitalmars-d-learn
On Saturday, 30 December 2017 at 16:23:05 UTC, Steven Schveighoffer wrote: On 12/29/17 7:03 AM, Mike Franklin wrote: Is that simply because it hasn't been implemented or suggested yet for D, or was there a deliberate design decision? It was deliberate, but nothing says it can't actually be

C++ interfaces and D dynamic arrays

2018-01-02 Thread Void-995 via Digitalmars-d-learn
Hi, everyone. I would like to have an interface that can be implemented and/or used from C++ in D. One of the things I would like to keep is the nice feature of D dynamic arrays in terms of bounding checks and "length" property. Let's assume: extern (C++) interface ICppInterfaceInD { ref

Re: Get aliased type

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/2/18 7:45 AM, John Chapman wrote: On Tuesday, 2 January 2018 at 12:19:19 UTC, David Nadlinger wrote: There is indeed no way to do this; as you say, aliases are just names for a particular reference to a symbol. Perhaps you don't actually need the names in your use case, though?  — David

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/2/18 8:57 AM, Adam D. Ruppe wrote: On Tuesday, 2 January 2018 at 11:22:06 UTC, Stefan Koch wrote: You can make it much faster by using a sliced static array as buffer. Only if you want data corruption! It keeps a copy of your pointer internally:

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 11:22:06 UTC, Stefan Koch wrote: You can make it much faster by using a sliced static array as buffer. Only if you want data corruption! It keeps a copy of your pointer internally: https://github.com/dlang/phobos/blob/master/std/zlib.d#L605 It also will always

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 10:27:11 UTC, Christian Köstlin wrote: After this I analyzed the first step of the process (gunzipping the data from a file to memory), and found out, that dlangs UnCompress is much slower than java, and ruby and plain c. Yeah, std.zlib is VERY poorly written.

Re: Slices and Dynamic Arrays

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/1/18 12:18 AM, Jonathan M Davis wrote: A big problem with the term slice though is that it means more than just dynamic arrays - e.g. you slice a container to get a range over it, so that range is a slice of the container even though no arrays are involved at all. So, you really can't rely

Re: Get aliased type

2018-01-02 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 12:19:19 UTC, David Nadlinger wrote: There is indeed no way to do this; as you say, aliases are just names for a particular reference to a symbol. Perhaps you don't actually need the names in your use case, though? — David The idea was to distinguish between a

Re: Get aliased type

2018-01-02 Thread David Nadlinger via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 11:42:49 UTC, John Chapman wrote: Because an alias of a type is just another name for the same thing you can't test if they're different. I wondered if there was a way to get the aliased name, perhaps via traits? (.stringof returns the original type.) There is

Get aliased type

2018-01-02 Thread John Chapman via Digitalmars-d-learn
Because an alias of a type is just another name for the same thing you can't test if they're different. I wondered if there was a way to get the aliased name, perhaps via traits? (.stringof returns the original type.) I can't use Typedef because I'm inspecting types from sources I don't

Re: Help optimizing UnCompress for gzipped files

2018-01-02 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 10:27:11 UTC, Christian Köstlin wrote: Hi all, over the holidays, I played around with processing some gzipped json data. First version was implemented in ruby, but took too long, so I tried, dlang. This was already faster, but not really satisfactory fast. Then

Help optimizing UnCompress for gzipped files

2018-01-02 Thread Christian Köstlin via Digitalmars-d-learn
Hi all, over the holidays, I played around with processing some gzipped json data. First version was implemented in ruby, but took too long, so I tried, dlang. This was already faster, but not really satisfactory fast. Then I wrote another version in java, which was much faster. After this I