Add optimisations
This commit is contained in:
parent
2eae55e08b
commit
aedccb1d30
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
7
.idea/discord.xml
Normal file
7
.idea/discord.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="PROJECT_FILES" />
|
||||||
|
<option name="description" value="" />
|
||||||
|
</component>
|
||||||
|
</project>
|
18
.idea/misc.xml
Normal file
18
.idea/misc.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MakefileSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<MakefileProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="version" value="2" />
|
||||||
|
</MakefileProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
4
Makefile
4
Makefile
@ -2,9 +2,9 @@ sourcefiles := $(shell find src/impl/ -name *.c)
|
|||||||
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
make build-main
|
make build
|
||||||
|
|
||||||
build-main:
|
build:
|
||||||
mkdir -p dist/ && \
|
mkdir -p dist/ && \
|
||||||
gcc -o dist/bf2c -I src/intf/ ${sourcefiles}
|
gcc -o dist/bf2c -I src/intf/ ${sourcefiles}
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include "popen2.h"
|
#include "popen2.h"
|
||||||
|
|
||||||
int is_arg(int ac, char **argv, char *arg) {
|
int is_arg(int ac, char **argv, char *arg) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ac < 2) return 0;
|
if (ac < 2) return 0;
|
||||||
for(int x=1; x < ac; x++)
|
for(int x=1; x < ac; x++)
|
||||||
if (0 == strcmp(argv[x], arg))
|
if (0 == strcmp(argv[x], arg))
|
||||||
@ -82,9 +85,9 @@ int main(int argc, char **argv) {
|
|||||||
"}\n\n", cellsize
|
"}\n\n", cellsize
|
||||||
);
|
);
|
||||||
|
|
||||||
a=1;
|
a = 1;
|
||||||
|
|
||||||
while (b!=EOF) {
|
while (b != EOF) {
|
||||||
c = getc(in);
|
c = getc(in);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '>':
|
case '>':
|
||||||
@ -96,13 +99,21 @@ int main(int argc, char **argv) {
|
|||||||
case '[':
|
case '[':
|
||||||
case ']':
|
case ']':
|
||||||
case EOF:
|
case EOF:
|
||||||
if (c!=EOF && b==c && optimise) a++;
|
if (c != EOF && b == c && optimise) a++;
|
||||||
else {
|
else {
|
||||||
switch (b) {
|
switch (b) {
|
||||||
case '>': addValueChange(out, "cell", true, a); break;
|
case '>':
|
||||||
case '<': addValueChange(out, "cell", false, a); break;
|
addValueChange(out, "cell", true, a);
|
||||||
case '+': addValueChange(out, "*cell", true, a); break;
|
break;
|
||||||
case '-': addValueChange(out, "*cell", false, a); break;
|
case '<':
|
||||||
|
addValueChange(out, "cell", false, a);
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
addValueChange(out, "*cell", true, a);
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
addValueChange(out, "*cell", false, a);
|
||||||
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
for (int i = 0; i < a; i++) fprintf(out, "putchar(*cell);\n");
|
for (int i = 0; i < a; i++) fprintf(out, "putchar(*cell);\n");
|
||||||
break;
|
break;
|
||||||
@ -115,7 +126,8 @@ int main(int argc, char **argv) {
|
|||||||
case ']':
|
case ']':
|
||||||
for (int i = 0; i < a; i++) fprintf(out, "}\n");
|
for (int i = 0; i < a; i++) fprintf(out, "}\n");
|
||||||
break;
|
break;
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset for next loop
|
// Reset for next loop
|
||||||
|
Loading…
Reference in New Issue
Block a user