summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBion <bionoren@gmail.com>2015-04-15 12:09:04 -0500
committerBion <bionoren@gmail.com>2015-04-15 12:09:04 -0500
commit5155395152a3ab23f38ca8d403a34ef04003102a (patch)
tree706a403155b50081e4572d60a490323bbdc52d9d
parent3a8b2a3c550d9ae1358026de20db9ea0127a7275 (diff)
downloadwebgrind-5155395152a3ab23f38ca8d403a34ef04003102a.zip
webgrind-5155395152a3ab23f38ca8d403a34ef04003102a.tar.gz
webgrind-5155395152a3ab23f38ca8d403a34ef04003102a.tar.bz2
Update Preprocessor.php
Added documentation, changed space indenting to tab indenting, other syntax changes to better match the style of the rest of the codebase.
-rw-r--r--library/Preprocessor.php44
1 files changed, 23 insertions, 21 deletions
diff --git a/library/Preprocessor.php b/library/Preprocessor.php
index 7f7714a..4b0616e 100644
--- a/library/Preprocessor.php
+++ b/library/Preprocessor.php
@@ -62,10 +62,10 @@ class Webgrind_Preprocessor
if(substr($line,0,3)==='fl='){
// Found invocation of function. Read functionname
list($function) = fscanf($in,"fn=%[^\n\r]s");
- $function = self::getCompressedName($function, 0);
+ $function = self::getCompressedName($function, false);
if(!isset($functions[$function])){
$functions[$function] = array(
- 'filename' => self::getCompressedName(substr(trim($line),3), 1),
+ 'filename' => self::getCompressedName(substr(trim($line),3), true),
'invocationCount' => 0,
'nr' => $nextFuncNr++,
'count' => 0,
@@ -90,7 +90,7 @@ class Webgrind_Preprocessor
} else if(substr($line,0,4)==='cfn=') {
// Found call to function. ($function should contain function call originates from)
- $calledFunctionName = self::getCompressedName(substr(trim($line),4), 0);
+ $calledFunctionName = self::getCompressedName(substr(trim($line),4), false);
// Skip call line
fgets($in);
// Cost line
@@ -159,22 +159,24 @@ class Webgrind_Preprocessor
}
- protected static function getCompressedName($name, $type=0)
- {
- global $compressedNames;
- if(preg_match("/\((\d+)\)(.+)?/", $name, $matches))
- {
- $functionIndex = $matches[1];
- if(isset($compressedNames[$type][$functionIndex]) && isset($matches[2]) == false)
- {
- $name = $compressedNames[$type][$functionIndex];
- }
- else
- {
- $name = trim($matches[2]);
- $compressedNames[$type][$functionIndex] = $name;
- }
- }
- return $name;
- }
+ /**
+ * Extract information from $inFile and store in preprocessed form in $outFile
+ *
+ * @param string $name String to parse (either a filename or function name line)
+ * @param int $isFile True if this is a filename line (since files and functions have their own symbol tables)
+ * @return void
+ **/
+ static function getCompressedName($name, $isFile){
+ global $compressedNames;
+ if(preg_match("/\((\d+)\)(.+)?/", $name, $matches)){
+ $functionIndex = $matches[1];
+ if(isset($compressedNames[$isFile][$functionIndex]) && isset($matches[2]) == false){
+ $name = $compressedNames[$isFile][$functionIndex];
+ } else{
+ $name = trim($matches[2]);
+ $compressedNames[$isFile][$functionIndex] = $name;
+ }
+ }
+ return $name;
+ }
}