タグ

パフォーマンスとcに関するxorphitusのブックマーク (2)

  • C言語における文字列連結 — KaoriYa

    C言語で文字列連結を行う。とても簡単に思えるけれど、実はパフォーマンスについて考えることもあるんだよ、というお話。 C言語で2つ文字列の連結して、1つの文字列にするプログラム(関数)を書けるでしょうか? ちょっとC言語でプログラミングを学んだことがあれば簡単ですよね。要求仕様としては2つの引数aとbをとり、どちらもNULターミネートな文字列で、その文字列をヒープから確保した領域で連結して戻り値として返す、という感じの動作です。ヨユーですね。ちょっと書いてみてください。 char* str_join(const char* a, const char* b) { char* p = malloc(strlen(a) + strlen(b) + 1); strcpy(p, a); strcat(p, b); return p; } こんな風に書いてしまったあなたは及第点です。個人的には失格です

  • Azul Systems - Cliff Click Jr.’s Blog

    Java vs C performance... again... September 7, 2009 I just foolishly got caught in a You-Tube discussion on Java vs C performance.  Foolish because You-Tube comments are a lousy way to present anything and because it's hard to keep the level of discourse scholarly.  And foolish especially for me because I've had this discussion so many times and it always comes out the same way... so here's

  • 1