<commit_before>// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library native;

import '../compiler.dart' show Compiler;
import '../elements/elements.dart';

export 'behavior.dart';
export 'enqueue.dart';
export 'js.dart';
export 'scanner.dart';
export 'ssa.dart';

bool maybeEnableNative(Compiler compiler, LibraryElement library) {
  String libraryName = library.canonicalUri.toString();
  if (library.entryCompilationUnit.script.name
          .contains('sdk/tests/compiler/dart2js_native') ||
      library.entryCompilationUnit.script.name
          .contains('sdk/tests/compiler/dart2js_extra') ||
      libraryName == 'dart:async' ||
      libraryName == 'dart:html' ||
      libraryName == 'dart:html_common' ||
      libraryName == 'dart:indexed_db' ||
      libraryName == 'dart:js' ||
      libraryName == 'dart:svg' ||
      libraryName == 'dart:_native_typed_data' ||
      libraryName == 'dart:web_audio' ||
      libraryName == 'dart:web_gl' ||
      libraryName == 'dart:web_sql' ||
      compiler.options.allowNativeExtensions) {
    return true;
  }
  return false;
}
<commit_msg>dart2js: Reduce calls to Uri.toString()<commit_after>// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library native;

import '../compiler.dart' show Compiler;
import '../elements/elements.dart';

export 'behavior.dart';
export 'enqueue.dart';
export 'js.dart';
export 'scanner.dart';
export 'ssa.dart';

const Iterable<String> _allowedDartSchemePaths = const <String>[
  'async',
  'html',
  'html_common',
  'indexed_db',
  'js',
  'svg',
  '_native_typed_data',
  'web_audio',
  'web_gl',
  'web_sql'
];

bool maybeEnableNative(Compiler compiler, LibraryElement library) {
  bool allowedTestLibrary() {
    String scriptName = library.entryCompilationUnit.script.name;
    return scriptName.contains('sdk/tests/compiler/dart2js_native') ||
        scriptName.contains('sdk/tests/compiler/dart2js_extra');
  }
  bool allowedDartLibary() {
    Uri uri = library.canonicalUri;
    if (uri.scheme != 'dart') return false;
    return _allowedDartSchemePaths.contains(uri.path);
  }

  return allowedTestLibrary() || allowedDartLibary();
}

{'fraction_non_alphanumeric': 0.13031161473087818, 'fraction_numerical': 0.005261027923917442, 'mean_word_length': 3.963855421686747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4540700', 'n_tokens_mistral': 793, 'n_tokens_neox': 774, 'n_words': 195}