Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drastic performance enhancement by using a perfect hash instead of an…
… sqlite3 database.
- Loading branch information
saurik
committed
Nov 19, 2009
1 parent
52df64f
commit 57e9ebe
Showing
11 changed files
with
201 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Cycript - Inlining/Optimizing JavaScript Compiler | ||
* Copyright (C) 2009 Jay Freeman (saurik) | ||
*/ | ||
|
||
/* Modified BSD License {{{ */ | ||
/* | ||
* Redistribution and use in source and binary | ||
* forms, with or without modification, are permitted | ||
* provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the | ||
* above copyright notice, this list of conditions | ||
* and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the | ||
* above copyright notice, this list of conditions | ||
* and the following disclaimer in the documentation | ||
* and/or other materials provided with the | ||
* distribution. | ||
* 3. The name of the author may not be used to endorse | ||
* or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
/* }}} */ | ||
|
||
#include <cstdlib> | ||
#include "Bridge.hpp" | ||
|
||
extern "C" struct CYBridgeEntry *CYBridgeHash(const char *data, size_t size) { | ||
return CYBridgeHash_(data, size); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
cat << EOF | ||
%{ | ||
#include <cstring> | ||
#include "Execute.hpp" | ||
%} | ||
%language=ANSI-C | ||
%define lookup-function-name CYBridgeHash_ | ||
%define slot-name name_ | ||
%struct-type | ||
%omit-struct-type | ||
%pic | ||
struct CYBridgeEntry { | ||
int name_; | ||
const char *value_; | ||
}; | ||
%% | ||
EOF | ||
|
||
grep '^[CFV]' "$1" | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$/\1\2, "\3"/'; | ||
grep '^[EST]' "$1" | sed -e 's/^S/3/;s/^T/4/;s/^E/5/' | sed -e 's/^5\(.*\)$/4\1 i/;s/"/\\"/g' | sed -e 's/^\([^ ]*\) \([^ ]*\) \(.*\)$/\1\2, "\3"/'; | ||
grep '^:' "$1" | sed -e 's/^: \([^ ]*\) \(.*\)/6\1, "\2"/'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* Cycript - Inlining/Optimizing JavaScript Compiler | ||
* Copyright (C) 2009 Jay Freeman (saurik) | ||
*/ | ||
|
||
/* Modified BSD License {{{ */ | ||
/* | ||
* Redistribution and use in source and binary | ||
* forms, with or without modification, are permitted | ||
* provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the | ||
* above copyright notice, this list of conditions | ||
* and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the | ||
* above copyright notice, this list of conditions | ||
* and the following disclaimer in the documentation | ||
* and/or other materials provided with the | ||
* distribution. | ||
* 3. The name of the author may not be used to endorse | ||
* or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
/* }}} */ | ||
|
||
#ifndef CYCRIPT_EXECUTE_HPP | ||
#define CYCRIPT_EXECUTE_HPP | ||
|
||
struct CYBridgeEntry { | ||
int name_; | ||
const char *value_; | ||
}; | ||
|
||
extern "C" struct CYBridgeEntry *CYBridgeHash(const char *data, size_t size); | ||
|
||
#endif/*CYCRIPT_EXECUTE_HPP*/ |
Oops, something went wrong.