[Tizen.Log] Replace getting filename with a primitive (fast) way
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 21 Jul 2022 01:45:20 +0000 (10:45 +0900)
committerhyotaekshim <35134695+hyotaekshim@users.noreply.github.com>
Thu, 21 Jul 2022 02:34:48 +0000 (11:34 +0900)
This enhances speed up to 5x faster than using library functions when
it comes to a burst call.

Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/Tizen.Log/Tizen/Log.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 1869852..3bb3854
@@ -16,6 +16,7 @@
 
 using System;
 using System.IO;
+using System.Linq;
 using System.Runtime.CompilerServices;
 using System.ComponentModel;
 
@@ -120,8 +121,9 @@ namespace Tizen
             }
             else
             {
-                Uri f = new Uri("file://" + file);
-                Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
+                string[] fileslice = file.Split(new char[] { '\\', '/' });
+                string filename = fileslice.Last();
+                Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", filename, func, line, message);
             }
         }
     }
@@ -226,8 +228,9 @@ namespace Tizen
             }
             else
             {
-                Uri f = new Uri("file://" + file);
-                Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
+                string[] fileslice = file.Split(new char[] { '\\', '/' });
+                string filename = fileslice.Last();
+                Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", filename, func, line, message);
             }
         }
     }
@@ -333,8 +336,9 @@ namespace Tizen
             }
             else
             {
-                Uri f = new Uri("file://" + file);
-                Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > [SECURE_LOG] %s", Path.GetFileName(f.AbsolutePath), func, line, message);
+                string[] fileslice = file.Split(new char[] { '\\', '/' });
+                string filename = fileslice.Last();
+                Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", filename, func, line, message);
             }
 #endif
         }