Skip to content

Commit

Permalink
对象池Put改为新的Return
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 28, 2024
1 parent 5a90283 commit af7b16f
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion XCode/Cache/EntityCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void ShowStatics()
if (Success > 0) sb.AppendFormat(",命中{0,11:n0}({1,6:P02})", Success, (Double)Success / Total);
sb.AppendFormat("\t[{0}]", typeof(TEntity).FullName);

XTrace.WriteLine(sb.Put(true));
XTrace.WriteLine(sb.Return(true));
}
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion XCode/Cache/SingleEntityCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void ShowStatics()
if (Success > 0) sb.AppendFormat(",命中{0,11:n0}({1,6:P02})", Success, (Double)Success / Total);
sb.AppendFormat("\t[{0}]", typeof(TEntity).FullName);

XTrace.WriteLine(sb.Put(true));
XTrace.WriteLine(sb.Return(true));
}
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion XCode/Common/SqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static class SqlBuilder
if (item.Value) sb.Append(" Desc");
}

return sb.Put(true);
return sb.Return(true);
}

/// <summary>获取排序子句</summary>
Expand Down
2 changes: 1 addition & 1 deletion XCode/DataAccessLayer/Common/DbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ private static String ChangeUnderline(String name)
sb.Append(ch);
}

return sb.Put(true);
return sb.Return(true);
}

/// <summary>格式化数据为SQL数据</summary>
Expand Down
2 changes: 1 addition & 1 deletion XCode/DataAccessLayer/DAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ private void FixIndexName(IDataTable table)
sb.Append(item);
}

di.Name = sb.Put(true);
di.Name = sb.Return(true);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions XCode/DataAccessLayer/DAL_DbOperate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private TResult QueryWrap<T1, T2, T3, TResult>(T1 k1, T2 k2, T3 k3, Func<IDbSess
Append(sb, k1);
Append(sb, k2);
Append(sb, k3);
key = sb.Put(true);
key = sb.Return(true);

if (cache.TryGetValue<TResult>(key, out var value)) return value!;
}
Expand Down Expand Up @@ -503,7 +503,7 @@ private async Task<TResult> QueryAsyncWrap<T1, T2, T3, TResult>(T1 k1, T2 k2, T3
Append(sb, k1);
Append(sb, k2);
Append(sb, k3);
key = sb.Put(true);
key = sb.Return(true);

if (cache.TryGetValue<TResult>(key, out var value)) return value!;
}
Expand Down
8 changes: 4 additions & 4 deletions XCode/DataAccessLayer/DAL_Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public Int32 Update(Object data, Object where, String? tableName = null)
}
}

var sql = sb.Put(true);
var sql = sb.Return(true);

return ExecuteWrap(sql, "", dps.ToArray(), (ss, s, t, p) => ss.Execute(s, CommandType.Text, p), nameof(Update));
}
Expand Down Expand Up @@ -474,7 +474,7 @@ private String GetUpdateSql(IDataTable table, IDataColumn[] columns, ICollection
}
sb.Length -= " And ".Length;

return sb.Put(true);
return sb.Return(true);
}

/// <summary>删除数据</summary>
Expand Down Expand Up @@ -512,7 +512,7 @@ public Int32 Delete(String tableName, Object where)
}
}

return (sb.Put(true), dps);
return (sb.Return(true), dps);
}

/// <summary>插入数据</summary>
Expand Down Expand Up @@ -590,7 +590,7 @@ public Task<Int32> UpdateAsync(Object data, Object where, String? tableName = nu
sb.AppendFormat("{0}={1}", pi.Name, p.ParameterName);
}

var sql = sb.Put(true);
var sql = sb.Return(true);

return ExecuteAsyncWrap(sql, "", dps.ToArray(), (ss, s, t, p) => ss.ExecuteAsync(s, CommandType.Text, p), nameof(UpdateAsync));
}
Expand Down
4 changes: 2 additions & 2 deletions XCode/DataAccessLayer/InsertBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public class InsertBuilder
sbValues.Append(database.FormatValue(field, value));
}

var ns = sbNames.Put(true);
var vs = sbValues.Put(true);
var ns = sbNames.Return(true);
var vs = sbValues.Return(true);
if (ns.IsNullOrEmpty()) return null;

if (dps.Count > 0) Parameters = dps.ToArray();
Expand Down
2 changes: 1 addition & 1 deletion XCode/DataAccessLayer/MetaData/DbMetaData_Negative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ public virtual String CreateIndexSQL(IDataIndex index)
var dcs = index.Table.GetColumns(index.Columns);
sb.AppendFormat(" On {0} ({1})", FormatName(index.Table), dcs.Join(",", FormatName));

return sb.Put(true);
return sb.Return(true);
}

public virtual String DropIndexSQL(IDataIndex index) => $"Drop Index {index.Name} On {FormatName(index.Table)}";
Expand Down
6 changes: 3 additions & 3 deletions XCode/DataAccessLayer/Model/IModelResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public virtual String GetName(String name)
sb.Append(item);
}
}
name = sb.Put(true);
name = sb.Return(true);
}
if (name.Length > 2 && (name == name.ToUpper() || name == name.ToLower()))
{
Expand Down Expand Up @@ -156,7 +156,7 @@ private static String ChangeUnderline(String name)
sb.Append(ch);
}

return sb.Put(true);
return sb.Return(true);
}

/// <summary>根据字段名等信息计算索引的名称</summary>
Expand Down Expand Up @@ -184,7 +184,7 @@ public virtual String GetName(IDataIndex di)
sb.Append('_');
sb.Append(di.Columns[i]);
}
return sb.Put(true);
return sb.Return(true);
}

/// <summary>获取显示名,如果描述不存在,则使用名称,否则使用描述前面部分,句号(中英文皆可)、换行分隔</summary>
Expand Down
2 changes: 1 addition & 1 deletion XCode/DataAccessLayer/SelectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public override String ToString()
if (!OrderBy.IsNullOrEmpty()) sb.Append(" Order By " + OrderBy);
if (!Limit.IsNullOrEmpty()) sb.Append(Limit.EnsureStart(" "));

return sb.Put(true);
return sb.Return(true);
}

/// <summary>获取记录数的语句</summary>
Expand Down
8 changes: 4 additions & 4 deletions XCode/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public virtual void CheckExist(Boolean isNew, params String[] names)
if (name.IsNullOrEmpty()) name = typeof(TEntity).Name;
sb.AppendFormat(" 的{0}已存在!", name);

throw new ArgumentOutOfRangeException(String.Join(",", names), this[names[0]], sb.Put(true));
throw new ArgumentOutOfRangeException(String.Join(",", names), this[names[0]], sb.Return(true));
}
}

Expand Down Expand Up @@ -921,7 +921,7 @@ public static IList<TEntity> FindAll(Expression? where, String? order, String? s
sb.AppendFormat("{0} {1}", fn, od);
}

order2 = sb.Put(true).Replace("★", ",");
order2 = sb.Return(true).Replace("★", ",");
}
#endregion

Expand Down Expand Up @@ -1244,7 +1244,7 @@ public static async Task<IList<TEntity>> FindAllAsync(Expression where, String?
sb.AppendFormat("{0} {1}", fn, od);
}

order2 = sb.Put(true).Replace("★", ",");
order2 = sb.Return(true).Replace("★", ",");
}
#endregion

Expand Down Expand Up @@ -1979,7 +1979,7 @@ public override String ToString()
if (Meta.FieldNames.Contains(dc.Name)) sb.Append(this[dc.Name]);
}

var vs = sb.Put(true);
var vs = sb.Return(true);
if (columns.Length > 1)
return $"[{vs}]";
else
Expand Down
16 changes: 8 additions & 8 deletions XCode/Entity/IEntityPersistence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ public virtual Int32 Insert(IEntitySession session, String[] names, Object[] val
//sbv.Append(SqlDataFormat(values[i], fs[names[i]]));
sbv.Append(db.FormatValue(column, values[i]));
}
var sn = sbn.Put(true);
var sv = sbv.Put(true);
var sn = sbn.Return(true);
var sv = sbv.Return(true);
return session.Execute($"Insert Into {session.FormatedTableName}({sn}) values({sv})");
}

Expand Down Expand Up @@ -476,7 +476,7 @@ private String Join(IEntitySession session, String[] names, Object[] values, Str
sb.Append(db.FormatValue(column, values[i]));
}

return sb.Put(true);
return sb.Return(true);
}
#endregion

Expand Down Expand Up @@ -609,8 +609,8 @@ private String Join(IEntitySession session, String[] names, Object[] values, Str
sbValues.Append(db.FormatValue(fi.Field, value));
}

var ns = sbNames.Put(true);
var vs = sbValues.Put(true);
var ns = sbNames.Return(true);
var vs = sbValues.Return(true);
if (ns.IsNullOrEmpty()) return null;

if (dps.Count > 0) parameters = dps.ToArray();
Expand Down Expand Up @@ -720,7 +720,7 @@ Boolean CheckIdentity(IDatabase db, FieldItem fi, Object? value, StringBuilder s
// 重置累加数据
if (dfs != null && dfs.Count > 0) entity.Addition?.Reset(dfs);

var str = sb.Put(true);
var str = sb.Return(true);
if (str.IsNullOrEmpty()) return null;

// Where条件里面的参数化
Expand Down Expand Up @@ -925,8 +925,8 @@ public virtual WhereExpression GetPrimaryCondition(IEntity entity)
sbValues.Separate(", ").Append(db.FormatParameterName(fi.Name));
}

var ns = sbNames.Put(true);
var vs = sbValues.Put(true);
var ns = sbNames.Return(true);
var vs = sbValues.Return(true);
if (ns.IsNullOrEmpty()) return null;

return $"Insert Into {session.FormatedTableName}({ns}) Values({vs})";
Expand Down
2 changes: 1 addition & 1 deletion XCode/Membership/LogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void WriteLog(String action, IEntity entity, String? error = null)
var category = fact.Table.DataTable.DisplayName;
if (category.IsNullOrEmpty()) category = type.GetDisplayName() ?? type.GetDescription() ?? type.Name;

var log = CreateLog(category, action, error.IsNullOrEmpty(), sb.Put(true), userid, name);
var log = CreateLog(category, action, error.IsNullOrEmpty(), sb.Return(true), userid, name);
log.LinkID = linkId;

log.SaveAsync();
Expand Down
4 changes: 2 additions & 2 deletions XCode/Membership/字典参数.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void SetList(IList list)
if (sb.Length > 0) sb.Append(',');
sb.Append(item);
}
SetValueInternal(sb.Put(true));
SetValueInternal(sb.Return(true));
}

/// <summary>设置名值对</summary>
Expand All @@ -290,7 +290,7 @@ public void SetHash(IDictionary dic)
if (sb.Length > 0) sb.Append(',');
sb.AppendFormat("{0}={1}", item.Key, item.Value);
}
SetValueInternal(sb.Put(true));
SetValueInternal(sb.Return(true));
}
#endregion
}
2 changes: 1 addition & 1 deletion XCode/Membership/菜单.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void SavePermission()
if (sb.Length > 0) sb.Append(',');
sb.AppendFormat("{0}#{1}", item.Key, item.Value);
}
SetItem(__.Permission, sb.Put(true));
SetItem(__.Permission, sb.Return(true));
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion XCode/Membership/角色.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void SavePermission()
if (sb.Length > 0) sb.Append(',');
sb.AppendFormat("{0}#{1}", item.Key, (Int32)item.Value);
}
SetItem(__.Permission, sb.Put(true));
SetItem(__.Permission, sb.Return(true));
}

/// <summary>当前角色拥有的资源</summary>
Expand Down
2 changes: 1 addition & 1 deletion XCode/Model/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String GetString(IDatabase? db, IDictionary<String, Object>? ps)
var sb = Pool.StringBuilder.Get();
GetString(db, sb, ps);

return sb.Put(true);
return sb.Return(true);
}

/// <summary>获取字符串</summary>
Expand Down
2 changes: 1 addition & 1 deletion XCode/Model/WhereExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public override void GetString(IDatabase? db, StringBuilder builder, IDictionary
}
}

builder.Append(sb.Put(true));
builder.Append(sb.Return(true));
}

private void GetString(IDatabase? db, StringBuilder builder, IDictionary<String, Object> ps, Expression exp)
Expand Down
2 changes: 1 addition & 1 deletion XCode/Tree/EntityTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public Boolean Contains(TKey key)
sb.Append(item[namekey]);
}
}
return sb.Put(true);
return sb.Return(true);
}

/// <summary>删除子级到本级的关系。导出数据前可以先删除关系,以减少导出的大小</summary>
Expand Down

0 comments on commit af7b16f

Please sign in to comment.