فهرست منبع

* Avoid memory allocation in IsNullOrWhitespace. Fix issue #39702

Michaël Van Canneyt 3 سال پیش
والد
کامیت
cab37732c4
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      rtl/objpas/sysutils/syshelp.inc

+ 8 - 1
rtl/objpas/sysutils/syshelp.inc

@@ -311,8 +311,15 @@ end;
 
 
 class function TStringHelper.IsNullOrWhiteSpace(const AValue: string): Boolean;
+const
+  LWhiteSpace = [#0..' '];
+var
+  I: SizeInt;
 begin
-  Result:=system.Length(SysUtils.Trim(AValue))=0;
+  for I:=1 to System.Length(AValue) do
+    if not (AValue[I] in LWhiteSpace) then
+      exit(False);
+  Result:=True;
 end;