Comments (7)
Just to clarify, are you running Rojo 7.4.1? If so, would it be possible for you to check if this happens on 7.4.0?
I think this is probably related to #854, but it's surprising behavior for the implementation we're using so I'd like to make sure.
from rojo.
This is indeed related to a detail of Lines
:
Lines 299 to 304 in b2f133e
When the iterator encounters a lone newline, it returns an empty string: Rust playground.
We can probably resolve this by doing something like
pub fn read_to_string_lf_normalized<P: AsRef<Path>>(&self, path: P) -> io::Result<Arc<String>> {
let path = path.as_ref();
let contents = self.inner.lock().unwrap().read_to_string(path)?;
- Ok(contents.lines().collect::<Vec<&str>>().join("\n").into())
+ Ok(contents.replace("\r\n", "\n").into())
}
from rojo.
Just to clarify, are you running Rojo 7.4.1? If so, would it be possible for you to check if this happens on 7.4.0?
I think this is probably related to #854, but it's surprising behavior for the implementation we're using so I'd like to make sure.
Yes, I'm using 7.4.1. I'm pretty new to Rojo so I'm not sure how to downgrade. Could you link me to a resource to learn how?
from rojo.
Yes, I'm using 7.4.1. I'm pretty new to Rojo so I'm not sure how to downgrade. Could you link me to a resource to learn how?
There's no need to do so now (Ken has identified that this is indeed an issue with our implementation).
For future reference though, it depends upon how you installed Rojo. If you used a toolchain manager like Aftman or Foreman, you'd just change the version in the relevant configuration file. Otherwise you'd have to go to the releases page and download an earlier version from there.
from rojo.
We can probably resolve this by doing something like
Sounds like a good idea to me, though I'd be worried about performance. The underlying implementation for String::replace
seems to use String::push_str
with no preallocation done, which seems... not ideal. Wonder if it's at all possible to implement it more efficiently.
from rojo.
We can probably resolve this by doing something like
Sounds like a good idea to me, though I'd be worried about performance. The underlying implementation for
String::replace
seems to useString::push_str
with no preallocation done, which seems... not ideal. Wonder if it's at all possible to implement it more efficiently.
I benchmarked the two approaches, and on my machine, the str::lines
approach is actually slower than str::replace
, and when str::replace
is given LF input (i.e. there are no matches), very significantly so:
Here is the code I used to benchmark:
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
pub fn benchmark_string_normalization(c: &mut Criterion) {
let mut group = c.benchmark_group("Line Ending Normalization");
for i in [
("lf_input", "Oh My Goodness\n".repeat(2000).as_str()),
("crlf_input", "Oh My Goodness\r\n".repeat(2000).as_str()),
] {
group.bench_with_input(BenchmarkId::new("string_replace", i.0), i.1, |b, s| {
b.iter_batched(
|| s.to_string(),
|s| {
let _ = s.replace("\r\n", "\n");
},
BatchSize::SmallInput,
)
});
group.bench_with_input(BenchmarkId::new("string_lines", i.0), i.1, |b, s| {
b.iter_batched(
|| s.to_string(),
|s| {
s.lines().collect::<Vec<&str>>().join("\n");
},
BatchSize::SmallInput,
)
});
}
group.finish();
}
criterion_group!(benches, benchmark_string_normalization);
criterion_main!(benches);
from rojo.
I guess that actually makes sense, but it's good to see the data on it. In that case I have no qualms about just using String::replace
.
from rojo.
Related Issues (20)
- Rojo tries to destroy services when removed from the project file HOT 1
- Default project does not build/sync correctly HOT 1
- The "rojo" executable remains open after closing VS Code. HOT 2
- Packages built with Rojo have script differences even if they are identical HOT 3
- Rojo doesn't apply font type from .rbmx files HOT 11
- warning "value cannot be converted to a number" on Billboard Gui's "MaxDistance" property HOT 1
- Add support for passing authorization data through the studio plugin HOT 3
- `rojo sourcemap` occasionally outputs invalid JSON HOT 2
- Rojo plugin should have a "Never" option for the confirmation behavior setting
- Rojo breaks outbound studio Roblox API requests HOT 3
- Omit `.project.json` when searching for a project file HOT 3
- High CPU usage and file not syncing when drafts mode is enabled HOT 6
- always crashing on start and during sync HOT 1
- Naming a luau file "Init" instead of "init" causes the special case to duplicate scripts
- Glob ignore paths doesn't work for projects that define content above their relative path
- Multiple instances being created for a single folder HOT 1
- Plugin cannot undo rbxm sync if the root instance has changed type HOT 2
- A `default.project.json` with an omitted `name` field sets the name of its top-level instance to `default` after subsequent changes
- Error with cargo install on windows machine HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rojo.