Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling a second time on overwrite ( bedrock ) #2485

Open
Shadowkitten47 opened this issue Sep 14, 2024 · 1 comment
Open

Compiling a second time on overwrite ( bedrock ) #2485

Shadowkitten47 opened this issue Sep 14, 2024 · 1 comment

Comments

@Shadowkitten47
Copy link

Detailed description of your suggestion

This is more a question but either way I want to know why.

export_codec.write(export_codec.compile(), Project.export_path); 

(line 708 of io.js)
Calls the compile function and sends it to write when saving below is Codec.write()

write(content, path) {
		if (fs.existsSync(path) && this.overwrite) {
			this.overwrite(content, path, path => this.afterSave(path))
		} else {
			Blockbench.writeFile(path, {content}, path => this.afterSave(path));
		}
	}

Witch if the file already exists sends to this.overwrite and if it's bedrock

var model = this.compile({raw: true})['minecraft:geometry'][0]

( line 1193 of bedrock.js in function .overwrite)

It calls this.compile AGAIN which I should have to say why this shouldn't be the case because this can really slow down performance on super large or complex bedrock models personally I'm trying to make models that already take 10min to compile I don't want another 10 minutes. On the alterative I think we you should call export_codec as raw from the beginning then stringifying it on write

@Shadowkitten47
Copy link
Author

Suggested changes

export_codec.write(export_codec.compile({raw: true}), Project.export_path)

( line 708 of io.js )
Make the initial compile raw

write(content, path) {
		if (fs.existsSync(path) && this.overwrite) {
			this.overwrite(content, path, path => this.afterSave(path))
		} else {
			Blockbench.writeFile(path, { content: autoStringify(content) }, path => this.afterSave(path));
		}
	}

( line 128 of codec.js, codec::write() )
add autoStringify on non-overwriting

var model = content['minecraft:geometry'][0]

( line 1193 of bedrock.js within function overwrite)
Use content rather than recompiling

obj[model_name] = content;

( line 400 of bedrock_old.js )
again use content rather than recompile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants