On Saturday, 25 October 2014 at 20:51:04 UTC, Walter Bright wrote:
http://www.quora.com/What-are-the-algorithms-required-to-solve-all-problems-using-C++-in-any-competitive-coding-contest

Anyone want to review these and see what we should add to Phobos?

Dear Mr. Bright.

Just can not now comment. Please see this code. test code and profililing log.

src\phobos\std\stdio.d: lines 361-373 ------------------------------- */ /*file and line in this is demo solve. Just for profilling. I now more safety way. */ this(string name, in char[] stdioOpenmode = "rb", string file = __FILE__, size_t line = __LINE__) @safe
    {
        import std.conv : text;
        import std.exception : ErrnoException;

        /*this(errnoEnforce(.fopen(name, stdioOpenmode),
text("Cannot open file `", name, "' in mode `",
                                stdioOpenmode, "'")),
                name); */
if (!.fopen(name, stdioOpenmode)) throw new ErrnoException(text("Cannot open file `", name, "' in mode `",
                                stdioOpenmode, "'"), file, line);
    }

file.d(test code)-----------------------------------------------------------

import std.stdio;

void main(string[] args)
{
                /*int i;
                int a[2];
                if(true) i = 3;
                a[i] = 3;*/
                auto fobj = File("hello2.d");
                scope(failure) writefln("scope(failure)");
                scope(exit) writefln("scope(exit)");
                writefln("end");
}

profiler log for file.d with old version phobos----------------------
------------------
            1   _Dmain
            7   main
_D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa       8       89      80
            8   _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv
------------------
            8   _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa
_D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv  8       9       9
------------------
            1   main
_Dmain  1       40831907        40831897
            1   _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa
------------------
main    0       0       0
            1   _Dmain
            7   _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa

======== Timer Is 3579545 Ticks/Sec, Times are in Microsecs ========

  Num          Tree        Func        Per
  Calls        Time        Time        Call

      1    11407010    11407007    11407007     _Dmain
8 24 22 2 pure nothrow char[] object._dup!(const(char), char)._dup(const(char)[]) 8 2 2 0 pure nothrow @nogc void object._doPostblit!(char)._doPostblit(char[])
      1           0           0           0     main

new version-------------------------------------------
------------------
            1   _Dmain
            7   main
_D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa       8       102     88
            8   _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv
------------------
            8   _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa
_D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv  8       14      14
------------------
            1   main
_Dmain  1       2336665 2336654
            1   _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa
------------------
main    0       0       0
            1   _Dmain
            7   _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa

======== Timer Is 3579545 Ticks/Sec, Times are in Microsecs ========

  Num          Tree        Func        Per
  Calls        Time        Time        Call

      1      652782      652779      652779     _Dmain
8 28 24 3 pure nothrow char[] object._dup!(const(char), char)._dup(const(char)[]) 8 3 3 0 pure nothrow @nogc void object._doPostblit!(char)._doPostblit(char[])
      1           0           0           0     main

I not check the other functions, because not sure that this style of coding is enough object oriented. It object only because that here you have objects.
if you need it, let's work.
Best regards.

Reply via email to