Can I modify a constant in the RTL class System.Classes.TStream and rebuild it at runtime in Delphi XE6?

前端 未结 2 1629
抹茶落季
抹茶落季 2020-12-10 04:14

I am trying to work around a known ugly performance limitation in System.Classes.pas, which has a 1980s era constant buffer limit ($F000) that looks like this:



        
2条回答
  •  死守一世寂寞
    2020-12-10 04:32

    Update 1: The suggestion below does not work for the Classes unit in XE6. The basic technique is sound and does solve similar problems. But for XE6, at least the Classes unit, it is not immediately obvious how to re-compile it.

    This appears to be a fault introduced in XE6 because this technique is meant to work and is officially endorsed by Embarcadero: http://blog.marcocantu.com/blog/2014_august_buffer_overflow_bitmap.html

    Update 2:

    In XE7, this problem no longer exists. It would appear that whatever was broken in XE6 has been fixed.


    You need the compiler options to match those used when the unit was compiled by Embarcadero. That's the reason why your implementation section only change fails when it seems like it ought to succeed.

    Start a default project and use CTRL + O + O to generate these options. I get

    {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N-,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
    

    when I do this in XE6.

    Put that at the top of your copy of the unit and you should be good to go. You can probably get away with a cut-down subset of these, depending on your host project options. In my code I find that:

    {$R-,T-,H+,X+}
    

    suffices.

提交回复
热议问题