Daniel Berger
Posts: 1383
Nickname: djberg96
Registered: Sep, 2004
|
Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
|
|
|
|
Latest win32-api enhancement - 'S' prototypes
|
Posted: Jul 19, 2008 11:15 PM
|
|
The latest installment of the win32-api library will support 'S' (string) prototypes, which will be a distinct entity from 'P' (pointer) prototypes. Users can use 'S' for const char* and 'P' for pass by reference char* buffers. Why the distinction? A few reasons.
First, with pointers we always have to assume mutability. That means making an internal rb_str_modify() call on every pointer, even when it wasn't necessary. That, in turn, lead to some subtle issues, like the fact that you couldn't pass frozen strings to API calls.
Second, it's faster. About 33% faster in my benchmarks, because we don't have to worry that the string will be modified. I don't want to exaggerate the benchmarks, though. The reality is that this will mostly only benefit the MSVCRT functions. Still, it's nice.
Third, I think it will be easier to deal with for other implementations like JRuby and IronRuby, if I ever get around to porting this library. I have a partially complete JRuby version, but references are a pain.
Read: Latest win32-api enhancement - 'S' prototypes
|
|