Errors, bugs, questions - page 2746

 
Koldun Zloy:

No. It is not yet known at compile time.

Then how does it help to avoid a huge number of checks when SymbolInfoTick is called tens of billions of times?

 
fxsaber:

Then how does it help to avoid a huge number of checks when SymbolInfoTick is called tens of billions of times?

It doesn't. It only helps not to copy the string itself unnecessarily.

 
Koldun Zloy:

No. It only helps not to copy the string itself unnecessarily.

Then obviously the string reference solution for SymbolInfo functions is the right one, if one wants more efficiency from the Optimizer.

 

My debugger refuses to work in one of my projects. Moreover, its behaviour is difficult to predict. Sometimes it just refuses to enter breakpoints. It also refuses to enter some functions. At first I thought the reason was updates (maybe something went wrong with debugging). But in other simpler programs everything seems to work. I haven't checked it much, though, because I'm working on my main project. It is quite complex and has 15 modules of my own design (I have not counted the number of standard modules). The main module contains up to 2000 lines. I thought maybe it's all about the complexity of the project... Also, in some places I use macros for repetitive code snippets. Also I use standard UI elements, such as CAppDialog, CCheckGroup, CComboBox, CButton etc. that I rewrote to the functionality of my program. Maybe the debugging doesn't work because of them... For example, the CCheckGroup::itemCheckState(const string item) method, which I specifically wrote, doesn't get debugged. The method finds item of check box and checks whether it's selected (its State):

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CCheckGroup::itemCheckState(const string item) {
  int total = m_strings.Total();
  
  if(total != m_states.Total())
    return -1;
    
  int i = 0;
  for(; i < total; i++) {
    if(m_strings.At(i) == item)
      return m_states.At(i);
  }
  
  return -1;
}

This is what kind of UI I ended up with:

UI

Some of the UI elements are temporarily classified. And here is a branch where I described how I overrode Show() and Hide() methods of CAppDialog element:https://www.mql5.com/ru/forum/338301 The compiler complained at that moment and a critical error occurred.

In the end the project compiles normally, the compiler doesn't generate any errors. But debugging fails and just doesn't show execution of some code fragments, functions, methods and so on.

As far as I understand, there may be several reasons for that.

  1. Complicated code of the project, use of macros
  2. Complicated code using standard UI elements, such as CAppDialog, CCheckGroup, CComboBox, CButton (for which I also wrote new methods and redefined some of existing ones)
  3. Debugger bug related to the new build (possible, unlikely).

Build and system info:

2020.05.21 09:35:09.325 Terminal MetaTrader 5 x64 build 2433 started for MetaQuotes Software Corp.

2020.05.21 09:35:09.326 Terminal Windows 10 build 14393, Intel Core i5-5200U @ 2.20GHz, 2 / 3 Gb memory, 61 / 380 Gb disk, IE 11, UAC, GMT+2

Has anyone had similar problems with the debugger and what might be the cause?
 
fxsaber:

It is obvious then, that a string reference solution for SymbolInfo functions is the right one, if one wants more efficiency from the Optimizer.

Everything is passed by reference anyway. The difference was only in ancient MQL4. And there are no checks when reading string.
 
Alexey Navoykov:
This link makes no sense, the developer said so. Everything is passed by the link as it is. The only difference was in ancient MQL4. And there are no checks when reading the string.

It's only tiring to make statements like that.

int f1( string Str )
{
  return((Str += Str) == Str);
}

int f2( string &Str )
{
  return((Str += Str) == Str);
}

int Bench1( const int Amount = 1 e8 )
{
  int Res = 0;
  string Str = NULL;
  
  for (int i = 0; i < Amount; i++)
    Res += f1(Str);
    
  Print(Res);
    
  return(Res);    
}

int Bench2( const int Amount = 1 e8 )
{
  int Res = 0;
  string Str = NULL;
  
  for (int i = 0; i < Amount; i++)
    Res += f2(Str);

  Print(Res);
    
  return(Res);    
}

void OnStart()
{
  BENCH(Bench1())
  BENCH(Bench2())

  BENCH(Bench1())
  BENCH(Bench2())
}


        100000000
        Time[Bench1()] = 727585
        100000000
        Time[Bench2()] = 657464
        100000000
        Time[Bench1()] = 794205
        100000000
        Time[Bench2()] = 670440
 
fxsaber:

It's only tiresome to make statements like that.


Maybe it's easier to write:

int f1( string Str )
{
  return(Str == NULL || Str == "");
}

?...

Why drink something like that?

int f1( string Str )
{
  return((Str += Str) == Str);
}
 
Mihail Matkovskij:

It may be easier to write:

There is a different kind of discussion.

 
fxsaber:

It's only tiring to make statements like that.

To avoid being unsubstantiated, give me a benchmark where the string does not change.
 
TheXpert:
To avoid being unsubstantiated, give me a benchmark for the tests where the string does not change.
int f1( const string Str )
{
  return(Str + "1" != Str);
}

int f2( const string &Str )
{
  return(Str + "1" != Str);
}
        10000000
        Time[Bench1()] = 334596
        10000000
        Time[Bench2()] = 338559
        10000000
        Time[Bench1()] = 384711
        10000000
        Time[Bench2()] = 344346
Reason: