Daniel Vasquez Lopez

Friday, April 16, 2004

Use Buffer.BlockCopy instead of Array.Copy for better performance

Buffer.BlockCopy is faster than Array.Copy when you are copying primitive arrays (arrays of type System.Int32, System.Char and so forth).
The reason is because (with base on the SSCLI implementation) both Buffer.Blockcopy and Array.Copy, call the method m_memmove (declared in comsystem.cpp) that copies data byte per byte from one array to another, but the major difference is that Array.Copy performs more validations and operations than Buffer.BlockCopy before calling m_memmove.
Buffer.BlockCopy just checks if bonderies are valid and if the array's data type is primitive, but Array.Copy checks thinks like type compatibility, casting, boxing, unboxing, among other things.

Monday, April 12, 2004

How to Break Software Security Book

It focuses on find bugs that cause security vulnerabilities in your software. I really think that you should read this book if you are involved in a testing or software engineering role in a project. Check this link to find out more details.
This book this is widely recommended by Michael Howard [MSFT], co-author of Writing Secure Code.