THRIFT-1485 Performance: pass large and/or refcounted arguments as "const"
Patch: Jens Geyer
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1228965 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/delphi/src/Thrift.Protocol.JSON.pas b/lib/delphi/src/Thrift.Protocol.JSON.pas
index dfab86b..3c54386 100644
--- a/lib/delphi/src/Thrift.Protocol.JSON.pas
+++ b/lib/delphi/src/Thrift.Protocol.JSON.pas
@@ -48,7 +48,7 @@
type
TFactory = class( TInterfacedObject, IProtocolFactory)
public
- function GetProtocol( trans: ITransport): IProtocol;
+ function GetProtocol( const trans: ITransport): IProtocol;
end;
private
@@ -126,12 +126,12 @@
// Push/pop a new JSON context onto/from the stack.
procedure ResetContextStack;
- procedure PushContext( aCtx : TJSONBaseContext);
+ procedure PushContext( const aCtx : TJSONBaseContext);
procedure PopContext;
public
// TJSONProtocolImpl Constructor
- constructor Create( aTrans : ITransport);
+ constructor Create( const aTrans : ITransport);
destructor Destroy; override;
protected
@@ -148,11 +148,11 @@
// Write the bytes in array buf as a JSON characters, escaping as needed
procedure WriteJSONString( const b : TBytes); overload;
- procedure WriteJSONString( str : string); overload;
+ procedure WriteJSONString( const str : string); overload;
// Write out number as a JSON value. If the context dictates so, it will be
// wrapped in quotes to output as a JSON string.
- procedure WriteJSONInteger( num : Int64);
+ procedure WriteJSONInteger( const num : Int64);
// Write out a double as a JSON value. If it is NaN or infinity or if the
// context dictates escaping, Write out as JSON string.
@@ -168,25 +168,25 @@
public
// IProtocol
- procedure WriteMessageBegin( aMsg : IMessage); override;
+ procedure WriteMessageBegin( const aMsg : IMessage); override;
procedure WriteMessageEnd; override;
- procedure WriteStructBegin(struc: IStruct); override;
+ procedure WriteStructBegin( const struc: IStruct); override;
procedure WriteStructEnd; override;
- procedure WriteFieldBegin(field: IField); override;
+ procedure WriteFieldBegin( const field: IField); override;
procedure WriteFieldEnd; override;
procedure WriteFieldStop; override;
- procedure WriteMapBegin(map: IMap); override;
+ procedure WriteMapBegin( const map: IMap); override;
procedure WriteMapEnd; override;
- procedure WriteListBegin( list: IList); override;
+ procedure WriteListBegin( const list: IList); override;
procedure WriteListEnd(); override;
- procedure WriteSetBegin( set_: ISet ); override;
+ procedure WriteSetBegin( const set_: ISet ); override;
procedure WriteSetEnd(); override;
procedure WriteBool( b: Boolean); override;
procedure WriteByte( b: ShortInt); override;
procedure WriteI16( i16: SmallInt); override;
procedure WriteI32( i32: Integer); override;
- procedure WriteI64( i64: Int64); override;
- procedure WriteDouble( d: Double); override;
+ procedure WriteI64( const i64: Int64); override;
+ procedure WriteDouble( const d: Double); override;
procedure WriteString( const s: string ); override;
procedure WriteBinary( const b: TBytes); override;
//
@@ -290,7 +290,7 @@
//--- TJSONProtocolImpl ----------------------
-function TJSONProtocolImpl.TFactory.GetProtocol( trans: ITransport): IProtocol;
+function TJSONProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;
begin
result := TJSONProtocolImpl.Create(trans);
end;
@@ -455,7 +455,7 @@
end;
-constructor TJSONProtocolImpl.Create( aTrans : ITransport);
+constructor TJSONProtocolImpl.Create( const aTrans : ITransport);
begin
inherited Create( aTrans);
@@ -487,7 +487,7 @@
end;
-procedure TJSONProtocolImpl.PushContext( aCtx : TJSONBaseContext);
+procedure TJSONProtocolImpl.PushContext( const aCtx : TJSONBaseContext);
begin
FContextStack.Push( FContext);
FContext := aCtx;
@@ -528,7 +528,7 @@
end;
-procedure TJSONProtocolImpl.WriteJSONString( str : string);
+procedure TJSONProtocolImpl.WriteJSONString( const str : string);
begin
WriteJSONString( SysUtils.TEncoding.UTF8.GetBytes( str));
end;
@@ -575,7 +575,7 @@
end;
-procedure TJSONProtocolImpl.WriteJSONInteger( num : Int64);
+procedure TJSONProtocolImpl.WriteJSONInteger( const num : Int64);
var str : String;
escapeNum : Boolean;
begin
@@ -676,7 +676,7 @@
end;
-procedure TJSONProtocolImpl.WriteMessageBegin( aMsg : IMessage);
+procedure TJSONProtocolImpl.WriteMessageBegin( const aMsg : IMessage);
begin
ResetContextStack; // THRIFT-1473
@@ -695,7 +695,7 @@
end;
-procedure TJSONProtocolImpl.WriteStructBegin( struc: IStruct);
+procedure TJSONProtocolImpl.WriteStructBegin( const struc: IStruct);
begin
WriteJSONObjectStart;
end;
@@ -707,7 +707,7 @@
end;
-procedure TJSONProtocolImpl.WriteFieldBegin( field : IField);
+procedure TJSONProtocolImpl.WriteFieldBegin( const field : IField);
begin
WriteJSONInteger(field.ID);
WriteJSONObjectStart;
@@ -726,7 +726,7 @@
// nothing to do
end;
-procedure TJSONProtocolImpl.WriteMapBegin( map: IMap);
+procedure TJSONProtocolImpl.WriteMapBegin( const map: IMap);
begin
WriteJSONArrayStart;
WriteJSONString( GetTypeNameForTypeID( map.KeyType));
@@ -743,7 +743,7 @@
end;
-procedure TJSONProtocolImpl.WriteListBegin( list: IList);
+procedure TJSONProtocolImpl.WriteListBegin( const list: IList);
begin
WriteJSONArrayStart;
WriteJSONString( GetTypeNameForTypeID( list.ElementType));
@@ -757,7 +757,7 @@
end;
-procedure TJSONProtocolImpl.WriteSetBegin( set_: ISet);
+procedure TJSONProtocolImpl.WriteSetBegin( const set_: ISet);
begin
WriteJSONArrayStart;
WriteJSONString( GetTypeNameForTypeID( set_.ElementType));
@@ -792,12 +792,12 @@
WriteJSONInteger( i32);
end;
-procedure TJSONProtocolImpl.WriteI64( i64: Int64);
+procedure TJSONProtocolImpl.WriteI64( const i64: Int64);
begin
WriteJSONInteger(i64);
end;
-procedure TJSONProtocolImpl.WriteDouble( d: Double);
+procedure TJSONProtocolImpl.WriteDouble( const d: Double);
begin
WriteJSONDouble( d);
end;