Информация об изменениях

Сообщение Re[51]: MS забило на дотнет. Питону - да, сишарпу - нет? от 10.09.2021 18:39

Изменено 10.09.2021 18:40 vdimas

Re[51]: MS забило на дотнет. Питону - да, сишарпу - нет?
Здравствуйте, Sinclair, Вы писали:

Вариант на FindChildV, который немного подшаманил.

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgBEBLbAcwDsJcGDmFwBuGvSasAcgFd8MKMLETGzFgCVZvIQpYBhCPgAOHADaKAyooBuwmCtprWWnRz0BJHYojHrUOzAHcScpTW1dGBYvDCVeXGUQyXVXSOidOISRFgANAA4kJMZLAAtsKGMAGWxgcLcFEJoAeiaAbQApDgwAcRheRWEACgwAT2MYCAAzQYAhbTASgB4ZiARFyphsSekIABMYRY4dAD40BiOMY+OASmuAXRpWy1jZMAxqkYhZDEGPr4wANJHXYsawAR1kfSE2DM9xoF0UvBhDEEUFeGAYc14C0WABVjjQAN40Bik87eKBIswMXEMAD6u2wGGwdBCZPJGERyNpDKZ2HIIQAxMYoDx8NgGAB3cq8I7cBi7Di4GoWBj6Sx0VAAThJZIRlO59MZzNIbL1FKpNKNfIAzGbSfrLTzjdgUPaOVzqc6+QBWd2Ow285mFXUOi2Bl0Adn94a91uZeRjnINcaD2C1Sc9VrTAEFMynsy6ZvmnfHsPoSxG+WxK6mXQBRWuFvkAMSFIrFEullLlDFggmgMDVGu1oYYLWINr7MEmVowJSVrQu5P2CDuAF5jrBZwBZGD4aAjHflXBlMwGWBMmCWYzYXiDbdluhnchIa5L3iru4hAC+NHhsZSEgTCkJi8wlPWCAYsS1Dsh0XS9P0ShgMMYwTNMFy3A8sFkpOQHTrOtIeJy+B4scD4zgw85KmB2JLPiTDENRuBnMuwIwAg1wMJuBEMAAqvEWxRDmuy7BRs7EExC64CwabPiuHHXO6eHMMBj6XrsEC8GYIxWhomy7AA8tpIzEfuZGDEcVHSbROIMZJzGsToCmcdxxy8QJyqTMJonifxgne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+jENtyCOdZ3J7HEOXT6HJ7Nos1PIsk5F9WcXl2+T6Cl47brkndsS75PWbnQnefNyK4L4dwuksaPrPLjRbBldhvB8btMLYzdpnrHS6giVH76kmNgIIi1lqCA6jMPABx8REkTlOWkzEKYuXGYSBg8sMB5IvUwKcadZ1R5j3HhKAFkyWjdx7ocd0ffAvml7+6BU/d6zIkH53HdXcUnd57vPq0CrGJBRM+vvv/fl87idM6DALpXReDdIv+f9hN+8RXl3gEyCYi8WchareC8vWOqdWAPeJnXQwLdb3Dfh+PVH69YPU+EDeoYFHt9riV8dV0Z3PCSfiM8Q6lqvG9Kz+h/Jg8r8s9I5U2jpX++j818MA2C2GmkLzn231ZjaiAPn2egr2Bk+m+ixDsnchdGRhBm+nRkgEf07hRm+m3jIgYGCm3hYQXiXhARXikTXmvHkUfBdGU3vQbhfUfmIFyy9jMDZlpC+jMEhEhXoOeUdnVk1m1mCj1igB+AwOExNm0W5VhlnRNjENj2iUATEXYUkX1RgWoL5FoPOXoJYBYLZg4MhCd3jifwOTJkXDfw4nA2VmiRj1nhoKrk5U4m5T1gxB4jsJIgcI9hiU4JgCmX3xvwzhhjkN/CAA=

Где только возможно стоит использовать readonly-модификатор метода, ReadOnlySpan.
Одно плохо, кривая сигнатура MemoryMarshal.CreateReadOnlySpan:
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ReadOnlySpan<T> CreateReadOnlySpan<T>(ref T reference, int length) => new ReadOnlySpan<T>(ref reference, length);

Должно было быть так:
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ReadOnlySpan<T> CreateReadOnlySpan<T>(in T reference, int length) => new ReadOnlySpan<T>(Unsafe.AsRef(reference), length);


Потому что в readonly-методах приходится делать так:
internal readonly ReadOnlySpan<Box<N, T>> Children => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(_children._data0), _childrenCount);


Что легко лечится своим каким-нить хелпером
public static SpanHelper {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ReadOnlySpan<T> CreateReadOnlySpan<T>(in T reference, int length) => MemoryMarshal.CreateReadOnlySpan(Unsafe.AsRef(reference), length);

}
Re[51]: MS забило на дотнет. Питону - да, сишарпу - нет?
Здравствуйте, Sinclair, Вы писали:

Вариант на FindChildV, который немного подшаманил.

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgBEBLbAcwDsJcGDmFwBuGvSasAcgFd8MKMLETGzFgCVZvIQpYBhCPgAOHADaKAyooBuwmCtprWWnRz0BJHYojHrUOzAHcScpTW1dGBYvDCVeXGUQyXVXSOidOISRFgANAA4kJMZLAAtsKGMAGWxgcLcFEJoAeiaAbQApDgwAcRheRWEACgwAT2MYCAAzQYAhbTASgB4ZiARFyphsSekIABMYRY4dAD40BiOMY+OASmuAXRpWy1jZMAxqkYhZDEGPr4wANJHXYsawAR1kfSE2DM9xoF0UvBhDEEUFeGAYc14C0WABVjjQAN40Bik87eKBIswMXEMAD6u2wGGwdBCZPJGERyNpDKZ2HIIQAxMYoDx8NgGAB3cq8I7cBi7Di4GoWBj6Sx0VAAThJZIRlO59MZzNIbL1FKpNKNfIAzGbSfrLTzjdgUPaOVzqc6+QBWd2Ow285mFXUOi2Bl0Adn94a91uZeRjnINcaD2C1Sc9VrTAEFMynsy6ZvmnfHsPoSxG+WxK6mXQBRWuFvkAMSFIrFEullLlDFggmgMDVGu1oYYLWINr7MEmVowJSVrQu5P2CDuAF5jrBZwBZGD4aAjHflXBlMwGWBMmCWYzYXiDbdluhnchIa5L3iru4hAC+NHhsZSEgTCkJi8wlPWCAYsS1Dsh0XS9P0ShgMMYwTNMFy3A8sFkpOQHTrOtIeJy+B4scD4zgw85KmB2JLPiTDENRuBnMuwIwAg1wMJuBEMAAqvEWxRDmuy7BRs7EExC64CwabPiuHHXO6eHMMBj6XrsEC8GYIxWhomy7AA8tpIzEfuZGDEcVHSbROIMZJzGsToCmcdxxy8QJyqTMJonifxgneSwOa4Pp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Z3J7HEOXT6HJ7Nos1PIsk5F9WcXl2+T6Cl47brkndsS75PWbnQnefNyK4L4dwuksaPrPLjRbBldhvB8btMLYzdpnrHS6giVH76kmNgIIi1lqCA6jMPABx8REkTlOWkzEKYuXGYSBg8sMB5IvUwKcadZ1R5j3HhKAFkyWjdx7ocd0ffAvml7+6BU/d6zIkH53HdXcUnd57vPq0CrGJBRM+vvv/fl87idM6DALpXReDdIv+f9hN+8RXl3gEyCYi8WchareC8vWOqdWAPeJnXQwLdb3Dfh+PVH69YPU+EDeoYFHt9riV8dV0Z3PCSfiM8Q6lqvG9Kz+h/Jg8r8s9I5U2jpX++j818MA2C2GmkLzn231ZjaiAPn2egr2Bk+m+ixDsnchdGRhBm+nRkgEf07hRm+m3jIgYGCm3hYQXiXhARXikTXmvHkUfBdGU3vQbhfUfmIFyy9jMDZlpC+jMEhEhXoOeUdnVk1m1mCj1igB+AwOExNm0W5VhlnRNjENj2iUATEXYUkX1RgWoL5FoPOXoJYBYLZg4MhCd3jifwOTJkXDfw4nA2VmiRj1nhoKrk5U4m5T1gxB4jsJIgcI9hiU4JgCmX3xvwzhhjkN/CAA=

Где только возможно стоит использовать readonly-модификатор метода, ReadOnlySpan.
Одно плохо, кривая сигнатура MemoryMarshal.CreateReadOnlySpan:
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ReadOnlySpan<T> CreateReadOnlySpan<T>(ref T reference, int length) => new ReadOnlySpan<T>(ref reference, length);

Должно было быть так:
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ReadOnlySpan<T> CreateReadOnlySpan<T>(in T reference, int length) => new ReadOnlySpan<T>(Unsafe.AsRef(reference), length);


Потому что в readonly-методах приходится делать так:
internal readonly ReadOnlySpan<Box<N, T>> Children => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(_children._data0), _childrenCount);


Что лечится своим каким-нить хелпером
public static SpanHelper {
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ReadOnlySpan<T> CreateReadOnlySpan<T>(in T reference, int length) => MemoryMarshal.CreateReadOnlySpan(Unsafe.AsRef(reference), length);
}