Skip to content

Commit

Permalink
Faster stringAppend of 6 strings
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Apr 12, 2016
1 parent 4759770 commit 9c0d484
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -148,6 +148,7 @@ import Lookup;
import MetaUtil;
import PrefixUtil;
import SCodeUtil;
import StringUtil;
import Static;
import Types;
import UnitParserExt;
Expand Down Expand Up @@ -5356,9 +5357,9 @@ protected function generateCachePath
protected
String name;
algorithm
name := InstTypes.callingScopeStr(callScope) + "$" +
SCodeDump.restrString(SCode.getClassRestriction(cls)) + "$" +
generatePrefixStr(prefix) + "$";
name := StringUtil.stringAppend6(InstTypes.callingScopeStr(callScope), "$",
SCodeDump.restrString(SCode.getClassRestriction(cls)), "$",
generatePrefixStr(prefix), "$");
cachePath := Absyn.joinPaths(Absyn.IDENT(name), FGraph.getGraphName(env));
end generateCachePath;

Expand Down
22 changes: 22 additions & 0 deletions Compiler/Util/StringUtil.mo
Expand Up @@ -348,5 +348,27 @@ algorithm
end for;
end stringHashDjb2Work;

function stringAppend6
input String str1,str2,str3,str4,str5,str6;
output String str;
protected
System.StringAllocator sb=System.StringAllocator(stringLength(str1)+stringLength(str2)+stringLength(str3)+stringLength(str4)+stringLength(str5)+stringLength(str6));
Integer c=0;
algorithm
System.stringAllocatorStringCopy(sb, str1, c);
c := c + stringLength(str1);
System.stringAllocatorStringCopy(sb, str2, c);
c := c + stringLength(str2);
System.stringAllocatorStringCopy(sb, str3, c);
c := c + stringLength(str3);
System.stringAllocatorStringCopy(sb, str4, c);
c := c + stringLength(str4);
System.stringAllocatorStringCopy(sb, str5, c);
c := c + stringLength(str5);
System.stringAllocatorStringCopy(sb, str6, c);
c := c + stringLength(str6);
str := System.stringAllocatorResult(sb,str1);
end stringAppend6;

annotation(__OpenModelica_Interface="util");
end StringUtil;

0 comments on commit 9c0d484

Please sign in to comment.