Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 12:19:36 UTC, Patrick Schluter wrote: On Thursday, 17 March 2022 at 12:11:19 UTC, Patrick Schluter wrote: On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter wrote: [...] Something akin to ```d auto lookup(ushort key) { return cp949[key-0x8141]; } [.

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 12:11:19 UTC, Patrick Schluter wrote: On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter wrote: [...] Something akin to ```d auto lookup(ushort key) { return cp949[key-0x8141]; } [...] Takes 165 ms to compile with dmd 2.094.2 -O on [godbolt] with t

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter wrote: On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows94

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16. After some rese

Re: Make shared static this() encoding table compilable

2022-03-16 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 18:40:35 UTC, zhad3 wrote: On Tuesday, 15 March 2022 at 03:01:05 UTC, Salih Dincer wrote: OMG, I gasp at my computer screen and waited for minutes. :) When you edit the code at the back-end level, you can use system resources in the best way. I think you should

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Tuesday, 15 March 2022 at 03:01:05 UTC, Salih Dincer wrote: OMG, I gasp at my computer screen and waited for minutes. :) When you edit the code at the back-end level, you can use system resources in the best way. I think you should start with [dlang.dmd.backend.aarray](https://github.com/d

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 22:20:42 UTC, rikki cattermole wrote: The recommended solution by Unicode is to use Trie tables for Look Up Tables (LUTs). https://en.wikipedia.org/wiki/Trie You can generate these as read only global arrays and are very fast for this. Thank your for this hint.

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 19:05:41 UTC, Ali Çehreli wrote: Yes, better but not much: 37 seconds vs. 50+ seconds on my system. Even though I am pretty sure the OP has access to the keys and the values separately, if it helps, I used the following code to separate the keys and values: [sn

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 10:23:18 UTC, bauss wrote: I think it's a memory issue and it's unlikely to be solved. I saw a similar issue a while ago where it worked with everything but DMD. Someone can correct me but if I remember correctly it's because DMD issues instructions for each value

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 10:07:52 UTC, Basile B. wrote: That's a compiler bug of type "ICE", the compiler crashes. Try reducing to a simple module that does not use phobos and report to bugzilla. Thank you and sorry for the late reply, I have been quite busy. You can test this already with

Re: Make shared static this() encoding table compilable

2022-03-14 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: [...] I usually compile my projects using LDC where this works fine, but I don't want to force others to use LDC because of this one problem. Hence I'd like to ask on how to change the code so that it compiles on DMD in release mode (wit

Re: Make shared static this() encoding table compilable

2022-03-14 Thread rikki cattermole via Digitalmars-d-learn
The recommended solution by Unicode is to use Trie tables for Look Up Tables (LUTs). https://en.wikipedia.org/wiki/Trie You can generate these as read only global arrays and are very fast for this.

Re: Make shared static this() encoding table compilable

2022-03-14 Thread Ali Çehreli via Digitalmars-d-learn
On 3/14/22 11:36, Ali Çehreli wrote: > I would experiment with two arrays holding corresponding keys and > values separately: > >ushort[] keys = /* ... */; >ushort[] values = /* ... */; > > And then building the AA from those. Hopefully, -O works better for that > case. Yes, better but n

Re: Make shared static this() encoding table compilable

2022-03-14 Thread Ali Çehreli via Digitalmars-d-learn
On 3/14/22 03:23, bauss wrote: > I think it's a memory issue and it's unlikely to be solved. I could not reproduce the issue but it takes close to 1 minute for 'dmd -O'. Something is definitely wrong there. :) A workaround could be the -lowmem switch: dmd -O -lowmem ... But still, I would

Re: Make shared static this() encoding table compilable

2022-03-14 Thread bauss via Digitalmars-d-learn
On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16. After some rese

Re: Make shared static this() encoding table compilable

2022-03-14 Thread Basile B. via Digitalmars-d-learn
On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16. After some rese

Make shared static this() encoding table compilable

2022-03-14 Thread zhad3 via Digitalmars-d-learn
Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16. After some research about how to initialize immutable associative arra