Autor Beitrag
AeroX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Sa 10.05.08 19:14 
hallo,
ich möchte meinen Programmen mehr Performance verleihen, und deshalb die ganzen vorprogrammierten
Methoden ersetzen.

ich habe mal ein Beispiel:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
private unsafe string InternalSubString(int startIndex, int length, bool fAlwaysCopy)
{
    if (((startIndex == 0) && (length == this.Length)) && !fAlwaysCopy)
    {
        return this;
    }
    string str = FastAllocateString(length);
    fixed (char* chRef = &str.m_firstChar)
    {
        fixed (char* chRef2 = &this.m_firstChar)
        {
            wstrcpy(chRef, chRef2 + startIndex, length);
        }
    }
    return str;
}


das ist die Methode in der Klasse String, wie ihr euch denken könnt.
(ich habe das mit Hilfe des "Lutz Roeder's .NET Reflector" (nochmal danke für den Tipp!)
entdeckt, und möchte gerne wissen, wie ich an die Methode "wstrcpy" komme!

geht das?
derDachs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Di 13.05.08 01:02 
Titel: Hi
Wie du hier gleich sehen wirst ist das Ding ne private statische fkt der Klasse String.
Den Sourcecode der fkt könntest du dann beispielsweise für eigene Schandtaten nehmen.

hier nochmal der Code von String:

www.koders.com/cshar...spx?s=DateTime#L2647

mfG derDachs
derDachs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Di 13.05.08 01:09 
Titel: Oh
ich bemerke gerade, daß du dich ja eigendlich schon dieses Codes bedient hast über det Rflector, nur nicht vollständig.
Nochmaldie fkt ist in der Klasse enthalten...

Sourcecodeoben durchsuchen.

mfG derDachs
AeroX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Di 13.05.08 13:29 
mein gott, bin ich blöd^^

tut mir leid
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 17.05.08 12:20 
user profile iconAeroX hat folgendes geschrieben:
hallo,
ich möchte meinen Programmen mehr Performance verleihen, und deshalb die ganzen vorprogrammierten
Methoden ersetzen.
Womit genau willst du sie ersetzen? Angesichts deiner bisherigen Threads glaube ich ehrlich gesagt nicht, dass du mal kurz eine bessere Implementierung als MSFT aus dem Hut ziehst :gruebel: .
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Sa 17.05.08 12:57 
user profile iconKhabarakh hat folgendes geschrieben:
Womit genau willst du sie ersetzen? Angesichts deiner bisherigen Threads glaube ich ehrlich gesagt nicht, dass du mal kurz eine bessere Implementierung als MSFT aus dem Hut ziehst :gruebel: .

So wie ich ihn verstanden habe will er anstatt String.Substring aufzurufen, wstrcpy direkt aufrufen. Aber das einzige, das du dann weglassen könntest wäre die if-Abfrage. Bringt so gut wie keinen Performanceschub und macht deinen Code nur schön unsauber. ;)