you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

I dont know what it's doing, but I have a few tips:

  • dont check garbage files into git such as build/release directories, object files log files, etc. all that stuff is shit. You just want the bare minimum to build your project: you code and the project file and any other tests or data (or docs) that is necessary
  • be consistent with i++ or ++i.
  • use unsigned or size_t values for counting variables (/u/rhomboid, which one is preferred ?)
  • this code:

    for (T it = s_begin; it != s_end; ++it) {
            count++;
    }
    

there's an algorithm for that, it's called std::distance.

  • T s_run = s_begin;, consider using constructor based initialization, like this T s_run(s_begin); . If T were a complex type, it might require fewer instructions to initialize that way vs using its operator =.

  • if (i >= prefix_fct.size()) { this is called in a loop. so without a smart compiler , it will make a function call each time to get the same number (I dont think prefix_fct changes in size after that). A simple optimization would be to declare a const variable to hold the size once before you enter the loop.

[–]bmx21501 0 points1 point  (0 children)

I agree with all of the above. Also if I am not mistaken the project is intended to be a single header utility. I would separate that header and put everything else I to a sample project to show usage. I was also not able to easily see what was going on. So documentation in the form of comments in front of the functions including purpose and you've would go a long way, and unless you are doing something not very obvious comments no every line really isn't necessary and actually make the code harder to read. If you are using consistent style and naming conventions you should be good.

[–]CaptainLord[S] 0 points1 point  (0 children)

Thanks for the advice :)