-
Content Count
523 -
Joined
-
Last visited
-
Days Won
6
Posts posted by Vandrovnik
-
-
1 hour ago, Dalija Prasnikar said:For instance, this would be faster way to achieve same results:
var total, num: Int64; begin total := 0; num := 3; while num <= 1000000000 do begin total := total + num; inc(num, 3); end; num := 5; while num <= 1000000000 do begin total := total + num; inc(num, 5); end; end;
I know that this is not exactly the answer you are looking for.
I think the result will not be the same - original code adds number 15 just once to the total, while your code will add it twice...
- 3
-
3 minutes ago, Ian Branch said:According to David & Jim on the Webinar - They are coming. No time frame but the inference was 'soon'.
Let's hope it wasn't "soon" from a geological perspective...
- 6
-
Is there Parnassus Parallel Debugger for Delphi 11.0? Debugging threads is a night mare for me, so I wanted to try this IDE enhancement, but did not found it in GetIt...
-
There is https://blogs.embarcadero.com/must-have-this-free-powerful-report-generator-for-your-windows-apps/ , I have not tried it.
- 1
-
Hello,
I am not able to start 1 Android app of 3 apps since migration to Delphi 11.
I did the "Revert system files to default" on Libraries.
It fails in FMX.Platform.Android, TPlatformAndroid.Create, on the line Activity.addListener(FActivityListener):
Please any ideas what can be wrong / how to repair it?
-
I suppose it will be more difficult to find information on docwiki.embarcadero.com using Google, because Google Bot probably most of the time also sees just errors...
- 1
-
Thank you! I will try it as soon as possible.
-
43 minutes ago, Anders Melander said:Added a translation integration API which allows the application being translated to control BTM.
Using this integration, when a form or control is focused in the application, then the corresponding module and property is selected in BTM.
The integration API is contained in the file amLocalization.Integration.Tracker.API.pasThis is very interesting, please are there instructions how to prepare the application to use this tracking?
-
On 2/24/2022 at 1:21 PM, tgbs said:There are several reports at their quality Portal
... and these are silently ignored, I guess 😞
[RSP-37138] Product documentation has been unavailable for several days - Embarcadero Technologies
Internal status: Validation. How much time does it need just to validate this problem?
-
2 hours ago, jeroenp said:It's flaky. Again.
It says it cannot connect to MySQL database server, so the problem would probably happen with newer MediaWiki, too.
-
Hello, Inno Setup is able to take a file which is out of the setup.exe and install it, so if they can distribute more then just one file, they can put logo.jpg etc. in the same directory (or a subdirectory, as in my example) and install would find it there.
[Files] Source: "{src}\Licence\*.*"; DestDir: "{app}\Bin"; Flags: external comparetimestamp; Components: Licence
- 1
-
I have copied Vcl.Consts.pas and System.SysConst.pas to my project folder. I have added them to my project and in them, made translations.
With each new version of Delphi, I use WinMerge to find differences and solve them, otherwise it does not compile anymore.
-
Hi,
I am using IBX on Windows (32 and 64bit) and Android (32 and 64bit). Database = Firebird (2.5 and 3.0). In Delphi 11, I have not found any problem.
- 2
-
I would first test the memory of the computer - for example, https://www.system-rescue.org/
It has a memtest included.
When memory is OK, then test disk...
-
37 minutes ago, dummzeuch said:Easy: Value1 will be 4, since Value2 > 0 and therefore Value1 will be assigned Value2+1 = 3+1 = 4.
So I guess your example has a bug. 😉
Ups, yes, it has a bug 🙂 I was reading it as
_Value1 := _Value1+1;
-
15 minutes ago, dummzeuch said:And other calls to that procedure might actually require an input value:
How should the compiler determine whether passing an uninitialized variable to procedure bla is a problem, without analyzing the procedure itself?
OK, when we change it to this, so there is an unitialized variable:
procedure bla(var _Value1: integer; _Value2: integer); begin if _Value2 > 0 then _Value1 := _Value2+1; end; procedure blub; var Value1: integer; begin bla(Value1, 3); writeln(Value1); end;
What will be the value of Value1? I would prefer to get a warning in this case.
-
4 minutes ago, Attila Kovacs said:Every time you compile on every parameter, not just the one, on every single. Every time.
How would that affect the compiler?
Thx, not for me.
And it's not even wrong. Why the hint?
From my point of view, it is wrong. For "var" parameters, I expect they are already initialized. For uninitialized variables, that are used as output, there is "out".
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Parameters_(Delphi)
- Out parameters are frequently used with distributed-object models like COM. In addition, you should use out parameters when you pass an uninitialized variable to a function or procedure.
- 1
-
2 minutes ago, Attila Kovacs said:Really? And what if the var in the sub-roc is passed further? How deep do you want the compiler work for you? What if the decision is based on a variant? Should the compiler evaluate every outcomes? How slow should be the compiler just for your entertainment? Buy TMS FixInsight, write unit tests and first of all, develop a coding pattern which doesn't even uses such pitfalls.
It does not have to look inside - it sees (immediatelly), that uninitialized variable is passed as "var" parameter. It means that I should initialize the variable, or change the procedure and use "out" parameter instead of "var".
- 1
-
1 hour ago, Attila Kovacs said:It's not the compilers job to do code analysis for you?
It helps to avoid mistakes.
Here it produces a warning: ([dcc32 Warning] Test79.dpr(22): W1036 Variable 'a' might not have been initialized)
procedure Test2; var a: integer; begin if a=1 then exit; end;
I believe it should be consistent and produce a warning in Kryvich's example, too.
-
25 minutes ago, Attila Kovacs said:I'll downvote it.
Why?
-
4 hours ago, Kryvich said:I created a minimal reproducible example for this case.
program TestInitialization; {$APPTYPE CONSOLE} procedure Test; procedure DoStuff(var a: Integer); begin if a = 0 then a := 1; end; var a: Integer; begin DoStuff(a); Writeln(a); end; begin Test; Readln; end.
It's strange that the compiler doesn't show a warning W1036 Variable 'a' might not have been initialized. This is definitely an oversight.
Please will you report it and post here the link? I would vote for it.
-
Do you get the same error when you specify full path to the .bmp file?
-
In my opinion, in these situation you sometimes have to ask the user. Even when data is sent to printer, it does not mean it was really printed OK (out of paper, damaged printout...).
-
Setting Grid.ParentFont to false seems to help.
Strange Benchmark Results; Am I Missing Something?
in I made this
Posted · Edited by Vandrovnik
I have tried this (will probably not work fine for MaxValue not divisible by Workers), it is 3.6 times faster than single thread on an old i7 CPU. I guess it should be possible to use IFuture<Int64>, but I do not know how to pass parameters to it...
It is easy to use tParallel.For, but there I used tInterlocked.Add(total, num), which resulted in much worse time than single thread.
const MaxValue=1000000000; type tCalcThread=class(tThread) public CalcFrom: integer; CalcTo: integer; Value: Int64; procedure Execute; override; end; procedure tCalcThread.Execute; var PartialTotal: Int64; num: integer; begin PartialTotal:=0; for num:=CalcFrom to CalcTo do if (num mod 3 = 0) or (num mod 5 = 0) Then inc(PartialTotal, num); Value:=PartialTotal; end; function PLoop32: Int64; const Workers = 8; Var total : Int64; Calcs: array[0..Workers-1] of tCalcThread; a: integer; begin total := 0; fillchar(Calcs, sizeof(Calcs), 0); try for a:=0 to Workers-1 do begin Calcs[a]:=tCalcThread.Create(true); Calcs[a].FreeOnTerminate:=false; Calcs[a].CalcFrom:=Int64(MaxValue)*a div Workers; Calcs[a].CalcTo:=Int64(MaxValue)*(a+1) div Workers-1; Calcs[a].Start; end; for a:=0 to Workers-1 do begin Calcs[a].WaitFor; inc(total, Calcs[a].Value); end; finally for a:=0 to Workers-1 do FreeAndNil(Calcs[a]); end; result := total; end;