@@ -124,11 +124,10 @@ private static int LuauError(IntPtr thread, string err) {
124124 }
125125
126126#if UNITY_EDITOR
127+ private static readonly Regex AnchorLinkPattern = new Regex ( @"(\S+\.lua):(\d+)" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
127128 private static string InjectAnchorLinkToLuaScript ( string logMessage ) {
128129 // e.g. "path/to/my/script.lua:10: an error occurred"
129- var rx = new Regex ( @"(\S+\.lua):(\d+)" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
130-
131- return rx . Replace ( logMessage , ( m ) => {
130+ return AnchorLinkPattern . Replace ( logMessage , ( m ) => {
132131 var scriptPath = m . Groups [ 1 ] . Value ;
133132 var line = m . Groups [ 2 ] . Value ;
134133
@@ -140,14 +139,10 @@ private static string InjectAnchorLinkToLuaScript(string logMessage) {
140139
141140 //when a lua thread prints something to console
142141 [ AOT . MonoPInvokeCallback ( typeof ( LuauPlugin . PrintCallback ) ) ]
143- static void printf ( LuauContext context , IntPtr thread , int style , int gameObjectId , IntPtr buffer , int length , IntPtr ptr ) {
142+ static void printf ( LuauContext context , IntPtr thread , int style , int gameObjectId , IntPtr buffer , int length ) {
144143 CurrentContext = context ;
145144
146- string res = LuauCore . PtrToStringUTF8 ( buffer , length ) ;
147- if ( res == null ) {
148- LuauPlugin . LuauFreeString ( ptr ) ;
149- return ;
150- }
145+ var res = LuauCore . PtrToStringUTF8 ( buffer , length ) ;
151146
152147#if UNITY_EDITOR
153148 if ( style == 1 || style == 2 ) {
@@ -169,14 +164,11 @@ static void printf(LuauContext context, IntPtr thread, int style, int gameObject
169164 Debug . LogWarning ( res , logContext ) ;
170165 } else if ( style == 2 ) {
171166 Debug . LogError ( res , logContext ) ;
172- //If its an error, the thread is suspended
167+ //If it's an error, the thread is suspended
173168 ThreadDataManager . Error ( thread ) ;
174- //GetLuauDebugTrace(thread);
175169 } else {
176170 Debug . Log ( res , logContext ) ;
177171 }
178-
179- LuauPlugin . LuauFreeString ( ptr ) ;
180172 }
181173
182174 [ AOT . MonoPInvokeCallback ( typeof ( LuauPlugin . ToStringCallback ) ) ]
0 commit comments