[geany/geany] 0bd958: json: Optimize memory usage by not collecting string values

Colomban Wendling git-noreply at xxxxx
Tue Feb 24 17:12:25 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 31 Jan 2015 21:14:50 UTC
Commit:      0bd95857041091a3d17d2c728ac0a69c8ea04c52
             https://github.com/geany/geany/commit/0bd95857041091a3d17d2c728ac0a69c8ea04c52

Log Message:
-----------
json: Optimize memory usage by not collecting string values

When a string is not used as an object property the parser doesn't
need to know its value.  Not collecting it into memory lowers memory
consumption and avoids high memory consumption with huge string values.


Modified Paths:
--------------
    tagmanager/ctags/json.c

Modified: tagmanager/ctags/json.c
10 lines changed, 7 insertions(+), 3 deletions(-)
===================================================================
@@ -138,7 +138,8 @@ static boolean isIdentChar (int c)
 	return (isalnum (c) || c == '+' || c == '-' || c == '.');
 }
 
-static void readToken (tokenInfo *const token)
+static void readTokenFull (tokenInfo *const token,
+						   boolean includeStringRepr)
 {
 	int c;
 
@@ -178,7 +179,8 @@ static void readToken (tokenInfo *const token)
 					break; /* break on invalid, unescaped, control characters */
 				else if (c == '"' || c == EOF)
 					break;
-				vStringPut (token->string, c);
+				if (includeStringRepr)
+					vStringPut (token->string, c);
 			}
 			vStringTerminate (token->string);
 			break;
@@ -209,6 +211,8 @@ static void readToken (tokenInfo *const token)
 	}
 }
 
+#define readToken(t) (readTokenFull ((t), FALSE))
+
 static void pushScope (tokenInfo *const token,
 					   const tokenInfo *const parent,
 					   const jsonKind parentKind)
@@ -287,7 +291,7 @@ static void parseValue (tokenInfo *const token)
 
 		do
 		{
-			readToken (token);
+			readTokenFull (token, TRUE);
 			if (token->type == TOKEN_STRING)
 			{
 				jsonKind tagKind = TAG_NULL; /* default in case of invalid value */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list