Check-in [73cbe7370b]
Overview
Comment:Slightly better optimizations
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 73cbe7370b299d6c0c26601e44080abb9f48faa98ae06ed196ed405e431985d0
User & Date: rkeene on 2019-05-03 22:30:03.227
Other Links: manifest | tags
Context
2019-05-03
22:38
Ensure consistent UTF-8 encoding is applied throughout the file handling process check-in: d99958bdd3 user: rkeene tags: trunk
22:30
Slightly better optimizations check-in: 73cbe7370b user: rkeene tags: trunk
22:18
Use adler32 to hash values check-in: fb9dd5d783 user: rkeene tags: trunk
Changes
28
29
30
31
32
33
34

35
36
37
38
39
40



41
42
43
44
45
46
47
48
49
50
51
52



53

54
55
56
57
58
59
60
28
29
30
31
32
33
34
35
36
37
38
39


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65







+




-
-
+
+
+












+
+
+
-
+








<?
	package require xvfs
	xvfs::main $argv
?>
static long xvfs_<?= $::xvfs::fsName ?>_nameToIndex(const char *path) {
	unsigned int pathHash;
	size_t pathLen;
	
	if (path == NULL) {
		return(XVFS_NAME_LOOKUP_ERROR);
	}
	
	pathHash = Tcl_ZlibAdler32(0, (const unsigned char *) path, strlen(path));

	pathLen = strlen(path);
	pathHash = Tcl_ZlibAdler32(0, (const unsigned char *) path, pathLen);
	switch (pathHash) {
<?
	for {set index 0} {$index < [llength $::xvfs::outputFiles]} {incr index} {
		set outputFile [lindex $::xvfs::outputFiles $index]
		set outputFileHash [zlib adler32 $outputFile 0]
		lappend outputFileHashToIndex($outputFileHash) $index
	}
	
	foreach {outputFileHash outputFileIndexes} [lsort -stride 2 -dictionary [array get outputFileHashToIndex]] {
?>		case <?= $outputFileHash ?>:
<?
			foreach outputFileIndex $outputFileIndexes {
				set outputFileName [lindex $::xvfs::outputFiles $outputFileIndex]
				set outputFileName [encoding convertto utf-8 $outputFileName]
				set outputFileNameLen [string length $outputFileName]
?>			if (strcmp(path, xvfs_<?= $::xvfs::fsName ?>_data[<?= $outputFileIndex ?>].name) == 0) {
?>			if (pathLen == <?= $outputFileNameLen ?> && memcmp(path, xvfs_<?= $::xvfs::fsName ?>_data[<?= $outputFileIndex ?>].name, pathLen) == 0) {
				return(<?= $outputFileIndex ?>);
			}
<?
			}
?>			break;
<?	} ?>
	}